V
V
Vitalij Rudyuk2016-11-11 18:01:34
Java
Vitalij Rudyuk, 2016-11-11 18:01:34

How to set a variable in value @RequestMapping in Java Spring?

For example, I have a variable,
private String adminPath="admin";
then I write like this

@RequestMapping(value = { "/${adminPath}" }, method = RequestMethod.GET)
    public String homeAdmin(ModelMap model) {
        model.addAttribute("path", "../templates/home/index");
        return "admin/layout/main";
    }

but nothing is substituted
I'm just learning java and spring, stumbled over this. Please help me understand how it works.
I need this so that later I can change the value of this variable to admin121212, for example, and I don’t have to change it everywhere

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vitaly Vitrenko, 2016-11-11
@Faradey

private static final String ADMIN_PATH = "admin";

@RequestMapping(value = ADMIN_PATH , method = RequestMethod.GET)
    public String homeAdmin(ModelMap model) {
        model.addAttribute("path", "../templates/home/index");
        return "admin/layout/main";
    }

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question