0

I create Simple MVC project in Spring. Defaultr generic a jsp pages. I try change jsp to html and i:

<beans:bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
    <beans:property name="prefix" value="/WEB-INF/views/" />
    <beans:property name="suffix" value=".jsp" />
</beans:bean> 

replace this:

<beans:bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
    <beans:property name="prefix" value="/WEB-INF/views/" />
    <beans:property name="suffix" value=".html" />
</beans:bean>

and create html page in views folder, but after changes and try run i have this error:

WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/myapp/WEB-INF/views/home.html] in DispatcherServlet with name 'appServlet'

Why i have this error? I only change jsp to html.

Ralph
  • 118,862
  • 56
  • 287
  • 383
The Nightmare
  • 701
  • 5
  • 16
  • 36

1 Answers1

2

The InternalResourceViewResolverdoes not forward the request to the view folder. Instead it is responsible for selecting the 'jsp' (or what ever) according to the return value of an Controller(Method). Like

@RequestMapping("home")
public ModelAndView controllerMethodForHome(){
     //will render /WEB-INF/views/homeView.html
     return new ModelAndView("homeView");
}

with:

<beans:bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
   <beans:property name="prefix" value="/WEB-INF/views/" />
   <beans:property name="suffix" value=".html" />
</beans:bean>

will return the /WEB-INF/views/homeView.html for localhost:8080/myApp/home


Maybe the thing you want to use is the static resource mapping

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

Have a look at this question/answer for an example

Community
  • 1
  • 1
Ralph
  • 118,862
  • 56
  • 287
  • 383