search

Home  >  Q&A  >  body text

java - spring.mvc.view.suffix configuration does not work in Spring boot

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?

怪我咯怪我咯2788 days ago2238

reply all(2)I'll reply

  • 阿神

    阿神2017-06-28 09:24:49

    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

    reply
    0
  • 大家讲道理

    大家讲道理2017-06-28 09:24:49

    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

    reply
    0
  • Cancelreply