【发布时间】:2018-09-27 07:22:16
【问题描述】:
我正在使用 Spring mvc 和 IDE (Rad 8.5.5) 和 Jetty Integration 版本 8 来创建一个小型 Web 应用程序。
当我尝试提交请求 http://localhost:9090/testJetty/index 时,Jetty 返回以下错误消息:WARN org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/testJetty /WEB-INF/views/index.jsp] 在 DispatcherServlet 中,名称为“appServlet”。
这是我的代码:
web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="3.0"
xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
<display-name>testJetty</display-name>
<servlet>
<servlet-name>app</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>app</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
</web-app>
app-servlet.xml:
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.3.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.3.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.3.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.3.xsd">
<context:component-scan base-package="test"/>
<!-- Enables the Spring MVC @Controller programming model -->
<mvc:annotation-driven />
<!-- Handles HTTP GET requests for /resources/** by efficiently serving
up static resources in the ${webappRoot}/resources directory -->
<mvc:resources mapping="/resources/**" location="/resources/" />
<!-- 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=".jsp" />
<beans:property name="viewClass"
value="org.springframework.web.servlet.view.JstlView" />
</beans:bean>
</beans:beans>
控制器:
package test;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
public class test {
@RequestMapping(value = "/index")
public String index(Model model) {
return "index";
}
}
以下要求不能更改: 1. 使用jdk 1.6编译的项目 2.春季版4 3. Javax-servlet-api-3.1.0
我不知道是什么问题。有任何想法吗? 谢谢。
【问题讨论】:
标签: jsp spring-mvc embedded-jetty