Note that there are some explanatory texts on larger screens.

plurals
  1. POSpringMVC giving 404 returning a view
    text
    copied!<p>I've got the following controller...</p> <pre><code>@Controller @RequestMapping(value = "/userManagement") public class UserManagementController { @RequestMapping(value = "/", method = RequestMethod.GET) public Object home(Locale locale, Model model) { logger.info("User management view controller loaded..."); return "userManagement"; } @RequestMapping(value = "/createUserView", method = RequestMethod.GET) public Object createUser(Locale locale, Model model) { logger.info("create controller loaded..."); return "createUser"; } </code></pre> <p>My servlet-context is setup with the following values...</p> <pre><code>&lt;beans:bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"&gt; &lt;beans:property name="prefix" value="/WEB-INF/views/" /&gt; &lt;beans:property name="suffix" value=".jsp" /&gt; &lt;/beans:bean&gt; </code></pre> <p>Now if I go to <code>http://localhost:8080/myapp/userManagement</code> then I get the view userManagement.jsp which is exactly what I want...</p> <p>But if I go to <code>http://localhost:8080/myapp/userManagement/createUserView</code> I get a 404 error. </p> <pre><code>NetworkError: 404 Not Found - http://localhost:8080/myapp/userManagement/createUserView" </code></pre> <p>What I don't see is why this would occur as I've set the requestMapping up exactly the same as above and in /WEB-INF/views I've got a createUser.jsp and userManagement.jsp </p> <p>Is there anything I'm doing wrong with regards to serving up the views from spring mvc?</p> <p>Thanks,</p> <p>EDIT : web.xml added below...</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5"&gt; &lt;context-param&gt; &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt; &lt;param-value&gt;/WEB-INF/spring/root-context.xml /WEB-INF/spring/security-app-context.xml /WEB-INF/spring/appServlet/servlet-context.xml&lt;/param-value&gt; &lt;/context-param&gt; &lt;filter&gt; &lt;filter-name&gt;springSecurityFilterChain&lt;/filter-name&gt; &lt;filter-class&gt;org.springframework.web.filter.DelegatingFilterProxy&lt;/filter-class&gt; &lt;/filter&gt; &lt;filter-mapping&gt; &lt;filter-name&gt;springSecurityFilterChain&lt;/filter-name&gt; &lt;url-pattern&gt;/*&lt;/url-pattern&gt; &lt;/filter-mapping&gt; &lt;listener&gt; &lt;listener-class&gt;org.springframework.web.context.ContextLoaderListener&lt;/listener-class&gt; &lt;/listener&gt; &lt;servlet&gt; &lt;servlet-name&gt;appServlet&lt;/servlet-name&gt; &lt;servlet-class&gt;org.springframework.web.servlet.DispatcherServlet&lt;/servlet-class&gt; &lt;init-param&gt; &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt; &lt;param-value&gt;/WEB-INF/spring/appServlet/servlet-context.xml&lt;/param-value&gt; &lt;/init-param&gt; &lt;load-on-startup&gt;1&lt;/load-on-startup&gt; &lt;/servlet&gt; &lt;servlet-mapping&gt; &lt;servlet-name&gt;appServlet&lt;/servlet-name&gt; &lt;url-pattern&gt;/&lt;/url-pattern&gt; &lt;/servlet-mapping&gt; &lt;/web-app&gt; </code></pre> <p>EDIT2: </p> <p>Also, if I go directly to the address in the browser rather than using Ajax (going to myapp/userManagement/createUserView I get the error...</p> <p>HTTP Status 404 - /myapp/WEB-INF/views/userManagement/createUserView.jsp so it appears to be looking at a directory too high (although the wrong filename too).</p> <p>EDIT3. </p> <p>Ok, it appears to be even when I do the following..</p> <pre><code> @Controller @RequestMapping(value = "/userManagement") public class UserManagementController { @RequestMapping(value = "/", method = RequestMethod.GET) public Object home(Locale locale, Model model) { logger.info("User management view controller loaded..."); return "createUser"; } </code></pre> <p>I'm still presented with the userManagement.jsp page, so it appears as if this return is not firing correctly, but I have no idea why. The logger detail does still get fired to the console so it is actually reaching there, just something odd with the way springmvc is returning the JSP.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload