我有以下代码...
@RequestMapping(value = "", method = RequestMethod.GET)
public String messages(Model model) {
model.addAttribute("apikey", "test");
return "index";
}
<link th:href="@{'https://maps.googleapis.com/maps/api/js?key=' + ${apikey}}" />
但是当我运行它时,我得到...
<link href="https://maps.googleapis.com/maps/api/js?key=null">
配置为...
@Bean
public InternalResourceViewResolver viewResolver() {
InternalResourceViewResolver viewResolver
= new InternalResourceViewResolver();
viewResolver.setViewClass(JstlView.class);
viewResolver.setPrefix("/WEB-INF/html/");
viewResolver.setSuffix("");
return viewResolver;
}
如何让它传递实际值?
更新
我将文件放在错误的文件夹中,因此我将html移至WEB-INF / html,但现在模板甚至无法呈现。