我有以下控制器...
@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";
}
我的servlet上下文是设置具有以下值...
<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>
现在,如果我去http://localhost:8080/myapp/userManagement
然后我得到的观点userManagement.jsp这正是我想要的...
但是,如果我去http://localhost:8080/myapp/userManagement/createUserView
我得到一个404错误。
NetworkError: 404 Not Found - http://localhost:8080/myapp/userManagement/createUserView"
我不看就是为什么,因为我已经设置了requestMapping完全一样,上面和/ WEB-INF /意见我有一个createUser.jsp和userManagement.jsp这会发生
这有什么,我有关于服务了从Spring MVC的意见做错了什么?
谢谢,
编辑:web.xml中添加如下...
<?xml version="1.0" encoding="UTF-8"?>
<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">
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring/root-context.xml
/WEB-INF/spring/security-app-context.xml
/WEB-INF/spring/appServlet/servlet-context.xml</param-value>
</context-param>
<filter>
<filter-name>springSecurityFilterChain</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>
<filter-mapping>
<filter-name>springSecurityFilterChain</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<servlet>
<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>
<servlet-mapping>
<servlet-name>appServlet</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
</web-app>
EDIT2:
另外,如果我直接去了地址在浏览器中,而不是使用Ajax(要MYAPP / userManagement / createUserView我得到的错误...
HTTP状态404 - /myapp/WEB-INF/views/userManagement/createUserView.jsp所以它似乎在寻找一个目录过高(尽管错误的文件名也是如此)。
EDIT3。
好吧,它出现时我这样做甚至可以说..
@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";
}
我仍然呈现与userManagement.jsp页面,所以它看起来仿佛这回不正确射击,但我不知道为什么。 该记录仪细节确实还被炒到控制台,以便它实际上是达到那里,只是一些奇怪的搭配方式是用SpringMVC返回JSP。