Using GSP views in plain Spring MVC without Grails

后端 未结 3 1942
借酒劲吻你
借酒劲吻你 2021-02-08 22:16

I would like to use GSP views instead of JSP/JSTL views in a plain old Spring MVC application. I have added a groovy.servlet.TemplateServlet to web.xml like this:



        
3条回答
  •  遇见更好的自我
    2021-02-08 23:09

    Instead of using a TemplateServlet, you could have also used a GroovyPagesServlet for that purpose (I haven't tested that, just looked at Grails' web.xml and the class' code).
    The latter requires a Spring bean to be setup, named groovyPagesTemplateEngine, and typed GroovyPagesTemplateEngine (GStringTemplateEngine in this case).

    Configuring the view layer with an InternalResourceViewResolver is correct. You'll have assigned a GroovyPageView.

    GSPs, by default, are not configured to perform HTML output escaping. To configure that, change grails.views.default.codec from none to html in Config.groovy. See this article for more information.

提交回复
热议问题