【发布时间】:2015-03-15 02:43:18
【问题描述】:
我一次又一次地遇到这个错误......
web.xml
<web-app id="WebApp_ID" version="2.4"
xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<display-name>brb</display-name>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>brb</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>brb</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
brb-servlet.xml
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd"
default-lazy-init="false">
<context:component-scan base-package="spring"/>
<mvc:annotation-driven/>
<bean class="org.springframework.web.servlet.view.UrlBasedViewResolver">
<property name="prefix" value="" />
<property name="suffix" value="" />
<property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/>
</bean>
<bean name="simple" class="spring.SimpleBean">
<constructor-arg index="0" value="1"/>
<constructor-arg index="1" value="1"/>
</bean>
控制器类是这样的:
@Controller
public class BrbController{
@RequestMapping(value = "/", method = GET)
public String index() {
System.out.println(this.getClass().getClassLoader().getResource("index.jsp")); // i check is file is available, actually I've coppied it in all resource directories presented
return "index.jsp";
}
我正在尝试让这个简单的应用程序在嵌入式 Jetty 下运行,但由于某种原因 spring mvc 看不到视图文件。
更新:我正在尝试打开“localhost:9123/”
【问题讨论】:
-
使用 what URI 查询时?
-
对不起。没提。只是 localhost:9123/
-
您是否已将应用程序映射到根目录?换句话说,'localhost:9123/' 是否解析为您的网络应用程序?如果没有,这可能会有所帮助 - stackoverflow.com/questions/8219148/…
-
我检查了:这肯定是我的应用程序,有警告:在 DispatcherServlet 中找不到带有 URI [/index.jsp] 的 HTTP 请求的映射,名称为 'org.springframework.web.servlet.DispatcherServlet- 284d5543' 一些静态响应体也可以正常工作
标签: java spring embedded-jetty