0

Here is my controller method:

@RequestMapping(value = "/login/{id}", method = RequestMethod.GET)
public String doLogin(@PathVariable long id, HttpServletRequest request, HttpServletResponse response, Model model) {

logger.info(String.format(
              Constants.LogMessages.NEW_GET_REQUEST_FROM_IP,
              request.getRemoteAddr()));

logger.info("/login/{id}");

return "login";

}

and my appServlet-context.xml:

    <!-- Resolves views selected for rendering by @Controllers to .jsp resources in the /WEB-INF/views directory -->
<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>

The exception i get in this method is :

WARN PageNotFound - No mapping found for HTTP request with URI [/project/WEB-INF/views/login.html] in DispatcherServlet with name 'appServlet'

Thing is, when i change the "suffix" to .jsp and the name of the file from html to .jsp it works.

any idea why?

EDIT:

Here is my web.xml:

<context-param>

<param-name>contextConfigLocation</param-name>

<param-value>/WEB-INF/spring/root-context.xml</param-value>

<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>

<servlet-name>appServlet</servlet-name>

<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>

<init-param>

  <param-name>contextConfigLocation</param-name>

  <param-value>/WEB-INF/spring/appServlet/servlet-context.xml</param-value>

</init-param>

<load-on-startup>1</load-on-startup>

<servlet-name>appServlet</servlet-name>

<url-pattern>/</url-pattern>

<filter-name>cors</filter-name>

<filter-class>src.com.project.context.CorsFilter</filter-class>

<filter-name>cors</filter-name>

<url-pattern>/*</url-pattern>

5
  • whether file /project/WEB-INF/views/login.html exists in the project? Commented Aug 23, 2013 at 16:23
  • Can you please show your configuration of DispatcherServlet in web.xml. Commented Aug 23, 2013 at 16:38
  • Sure! posted in original message Commented Aug 23, 2013 at 16:45
  • And what server are you using? Tomcat? Commented Aug 23, 2013 at 17:15
  • this helped me solve my problem: stackoverflow.com/questions/4249622/using-html-files-as-jsps Commented Aug 23, 2013 at 22:34

2 Answers 2

1

In your .xml file try changing:

<servlet-name>appServlet</servlet-name>

<url-pattern>/</url-pattern>

To:

<servlet-name>appServlet</servlet-name>

<url-pattern>*.html</url-pattern>
Sign up to request clarification or add additional context in comments.

Comments

0

Just a thought. May be your build process didn't copy the /project/WEB-INF/views/login.html file into the war. Unwar and check if that exists.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.