用于JSP的Spring MVC模板解析器

时间:2016-02-17 14:58:44

标签: jsp spring-mvc

我实际上使用的是Spring MVC,Spring Security和Thymeleaf。 如何在我的应用程序中添加使用jsp的可能性?

我尝试将这些行添加到我的 applications.properties

spring.mvc.view.prefix=classpath:/templates/jsp/
spring.mvc.view.suffix=.jsp

我的想法是我希望能够在文件夹中使用jsp SRC /主/资源/模板/ JSP / 和sme / main / resources / templates / thymeleaf /

中的thymeleaf html文件

我的控制器

@Controller
public class HelloJSP {
    @RequestMapping("/jsp")
    public String helloJSP() {
        return "hello";
    }
}

我的hello.jsp位于文件夹src / main / ressources / templates / jsp / hello.jsp

我是否需要在Spring安全性资源处理程序中注册某些jsp资源?

1 个答案:

答案 0 :(得分:0)

轻松修复

更改

spring.mvc.view.prefix=classpath:/templates/jsp/

spring.mvc.view.prefix=classpath:/templates/

每当你想从jsp或thymeleaf创建一个视图时,在那里添加前缀,例如“jsp / my_jsp_page”和“thymeleaf / my_thymeleaf_page”

参考:How to use multiple places in Spring viewresolver?

相关问题