使用以下代码片段时:
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
。我错了吗?如何解决这个问题?