当使用下面的代码片段:用于注释属性RequestMapping.value值必须是常量表达式
public class MyUrls {
// properties get initialized using static{...}
public final static String URL_HOMEPAGE = properties.getProperty("app.homepage");
}
@Controller
public class HomepageController {
@RequestMapping(MyUrls.URL_HOMEPAGE)
public String homepage() {
return "/homepage/index";
}
}
我得到以下错误:
The value for annotation attribute RequestMapping.value must be a constant expression
但事实上,URL_HOMEPAGE
确实是因为它被声明为public final static
。我错了吗?如何解决这个问题?