1
1
12014-03-28 18:45:45
Java
1, 2014-03-28 18:45:45

How to make Spring + JSP + Thymeleaf friends?

Is it possible to "make friends" with them? setOrder() doesn't help.

Start page - JSP, resolved through UrlBasedViewResolver. Throw some example, for example, on github.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
anyd3v, 2014-03-30
1

Too lazy to fill in a turnip here is the link https://dl.dropboxusercontent.com/u/53222029/sprin...
I worked with spring, but I am not a pro in it (as I already said). The thymeleaf docs have an example www.thymeleaf.org/doc/html/Thymeleaf-Spring3.html#... . As I understand it, setting only one order is not enough, although in my mind for some reason it was also that the logic would be the following: resolvers are sorted by order, then we take the first result without exception.
In the same case, all the magic came down to filtering viewNames, all that is required of
you is to add permissions to implement, and write with permission in controllers, I think that this is more than enough.
And yes, this viewNames parameter can be used as you like, you can filter by folder, by permission, write an array etc.

1
1 1, 2014-03-28
@ABCQ

To begin with, present your own version, Google gives out quite a few articles and solutions on SO

if you meant configuration, then everything is standard, something like this
<bean id="viewResolver"
class="org.springframework.web.servlet.view.UrlBasedViewResolver">
<property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/>
<property name="prefix" value="/WEB-INF/jsp/"/>
<property name="suffix" value=".jsp"/>
<property name="order" value="1">
</bean>

<bean id="templateResolver" class="org.thymeleaf.templateresolver.ServletContextTemplateResolver">
<property name="prefix" value="/WEB-INF/templates/" />
<property name="templateMode" value="HTML5" />
<property name="characterEncoding" value="UTF-8" />
</bean>
    
<bean id="templateEngine" class="org.thymeleaf.spring3.SpringTemplateEngine">
<property name="templateResolver" ref="templateResolver" />
<property name="additionalDialects">
<set>
<bean class="org.thymeleaf.extras.springsecurity3.dialect.SpringSecurityDialect" />
</set>
</property>
</bean>
    
<bean id="ThymeleafResolver" class="org.thymeleaf.spring3.view.ThymeleafViewResolver">
<property name="templateEngine" ref="templateEngine" />
<property name="characterEncoding" value="UTF-8" />
<property name="order" value="2">
</bean>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question