在spring MVC中,url模式斜杠星与InternalResourceViewResolver无法正常工作

时间:2015-12-27 02:58:19

标签: spring-mvc servlets java-ee web.xml tomcat8

下面是我的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_3_0.xsd"
	xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
	id="WebApp_ID" version="3.0">
	<display-name>Welcome</display-name>
	<servlet>
		<servlet-name>dispatcher</servlet-name>
		<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
		<load-on-startup>1</load-on-startup>
	</servlet>
	<servlet-mapping>
		<servlet-name>dispatcher</servlet-name>
		<url-pattern>/*</url-pattern>
	</servlet-mapping>
	<listener>
		<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
	</listener>
	<context-param>
		<param-name>contextConfigLocation</param-name>
		<param-value>
			/WEB-INF/dispatcher-servlet.xml,
			/WEB-INF/spring-security.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>

	<session-config>
		<tracking-mode>COOKIE</tracking-mode>
	</session-config>
 </web-app>

调度程序servlet能够找到为主页定义的控制器,如下所示

@RequestMapping(value = "/", method = RequestMethod.GET)
public String showWelcomePage(HttpServletRequest request,
        HttpServletResponse response, ModelMap model, Principal principal)
{
    return "home";
}

但它无法找到“家”的观点。它在日志中给出以下错误

INFO [http-nio-8080-exec-2] [2015-12-26 21:43:33,184] [Interceptor.java:34] - RequestURL - http://localhost:8080/mywebsite。 QueryString - null。 RequestUri - / mywebsite。客户端IP - 0:0:0:0:0:0:0:1。 0:0:0:0:0:0:0:1。用户代理 - Mozilla / 5.0(Windows NT 6.1; rv:43.0)Gecko / 20100101 Firefox / 43.0

WARN [http-nio-8080-exec-2] [2015-12-26 21:43:33,548] [DispatcherServlet.java:1165] - 找不到带URI的HTTP请求的映射[/ mywebsite / WEB-INF /patp/home.jsp]在DispatcherServlet中,名称为“dispatcher”

当我定义了以下dispatcher-servlet.xml

时,我似乎无法确定它为什么要搜索[/mywebsite/WEB-INF/jsp/home.jsp]
    <bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver"
    p:prefix="/WEB-INF/jsp/" p:suffix=".jsp" />

0 个答案:

没有答案