lidl lidl - 6 months ago 25
Java Question

Spring MVC load page without controller

With Spring MVC, when I am going to load one page as JSP, HTML etc, I have to write one controller for it.

How can I load one page directly without controller but in rules, just like structs 2.5?

Answer

Your DispatcherServlet is presumably mapped to "/", @Sotirios Delimanolis is right, and if you are still confusing, try

(1)use resources element

<mvc:resources mapping="/resources/**" location="/resources/"/>

Using org.springframework.web.servlet.resource.ResourceHttpRequestHandler to handle your static rsources. This is usually better than(2) because spring mvc attached some useful features when serving your resources.

(2)use default-servlet-handler

<mvc:default-servlet-handler/>

Declaring org.springframework.web.servlet.resource.ResourceHttpRequestHandler for serving static files using the Servlet container's "default" Servlet.

Comments