java - spring.mvc.view.suffix configuration does not work in Spring boot
怪我咯
怪我咯 2017-06-28 09:22:49
0
2
2160

New to Spring boot, I wrote a home method in the Controller to return a homePage view.
Thinking of the past in spring-mvc, you can configure suffix to specify the suffix of the access path.
After searching, the official website introduced such a configuration, spring.mvc.view.suffix. Then I added spring.mvc.view.suffix=.html to application.properties and found that whether I accessed localhost:8080/home or localhost:8080/home.html, I could get the correct view.
How to make only access paths ending with .html valid? Why doesn't this configuration here work?

怪我咯
怪我咯

走同样的路,发现不同的人生

reply all(2)
阿神

The urls of spring boot are all rest style. If you want to specify the url suffix, refer to my previous answer about spring boot custom url suffix

大家讲道理

The spring.mvc.view.suffix=.html configured here and the

in sping mvc
<bean id="jspViewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
    <property name="viewClass" value="org.springframework.web.servlet.view.JstlView" />
    <property name="prefix" value="/WEB-INF/jsp/" />
    <property name="suffix" value=".jsp" />
</bean>

This has the same function, it is not the requested suffix. The requested suffix is ​​filtered and configured in your configuration class

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!