我正在尝试运行第一个 Spring 3 MVC 设置。
我的应用程序在 tomcat 上运行,在“grapevine”的服务器上下文中
出于测试的目的,我正在尝试从中获取请求http://localhost:8080/grapevine/test
以呈现WEB-INF/jsp/noSuchInvitation.jsp
当我尝试这个时,我得到一个404
,并且日志表明我的 jsp 不存在:
WARN org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/grapevine/WEB-INF/jsp/noSuchInvitation.jsp] in DispatcherServlet with name 'grapevine'
我一定是在某个地方错误地配置了这个,但我看不出我做错了什么。
这是所有相关的片段。
Web.xml:
<servlet>
<servlet-name>grapevine</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>grapevine</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
从我的情况来看:
<mvc:annotation-driven />
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/jsp/"/>
<property name="suffix" value=".jsp"/>
</bean>
控制器:
@Controller
public class ParticipantInvitationController {
@RequestMapping("/test")
public ModelAndView test()
{
return new ModelAndView("noSuchInvitation");
}
日志:
DEBUG org.springframework.web.servlet.DispatcherServlet - Rendering view [org.springframework.web.servlet.view.JstlView: name 'noSuchInvitation'; URL [/WEB-INF/jsp/noSuchInvitation.jsp]] in DispatcherServlet with name 'grapevine'
DEBUG org.springframework.web.servlet.view.JstlView - Forwarding to resource [/WEB-INF/jsp/noSuchInvitation.jsp] in InternalResourceView 'noSuchInvitation'
DEBUG org.springframework.web.servlet.DispatcherServlet - DispatcherServlet with name 'grapevine' processing GET request for [/grapevine/WEB-INF/jsp/noSuchInvitation.jsp]
WARN org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/grapevine/WEB-INF/jsp/noSuchInvitation.jsp] in DispatcherServlet with name 'grapevine'
DEBUG org.springframework.security.web.context.HttpSessionSecurityContextRepository - SecurityContext contents are anonymous - context will not be stored in HttpSession.
DEBUG org.springframework.web.servlet.DispatcherServlet - Successfully completed request