Redian新闻
>
servlet-mapping causing http 404 error
avatar
servlet-mapping causing http 404 error# Java - 爪哇娇娃
z*e
1
我在看这个tutorial
http://docs.spring.io/docs/Spring-MVC-step-by-step/part1.html
但是发现在web.xml里面加入了这一段dispatcher的话,这个app就在tomcat里面不能运
行,如果不用这一段dispatcher倒是可以,怎么解决这个问题?

springapp
org.springframework.web.servlet.DispatcherServletservlet-class>
1


springapp
*.htm
avatar
s*y
2
包都到全了吗?
有报错信息吗?
avatar
z*e
3

这个是什么意思?不明白
我在tomcat manager里面看到的running app显示这个springapp的running 状态是
false,我在tomcat manager尝试start这个app的时候message: FAIL - Application
at context path /springapp could not be started
尝试访问localhost:8080/springapp/的时候,浏览器里显示
HTTP Status 404 - /springapp/
type Status report
message /springapp/
description The requested resource is not available.
Apache Tomcat/6.0.41
我的./springapp/war/WEB-INF/web.xml文件是

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">

springapp
org.springframework.web.servlet.DispatcherServletservlet-class>
1


springapp
/*.htm



index.jsp



./springapp/war/WEB-INF/springapp-servlet.xml文件是

http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">




【在 s****y 的大作中提到】
: 包都到全了吗?
: 有报错信息吗?

avatar
l*n
4
你看的东西太老,还在用ant,现在都gradle和spring 4.

【在 z*********e 的大作中提到】
:
: 这个是什么意思?不明白
: 我在tomcat manager里面看到的running app显示这个springapp的running 状态是
: false,我在tomcat manager尝试start这个app的时候message: FAIL - Application
: at context path /springapp could not be started
: 尝试访问localhost:8080/springapp/的时候,浏览器里显示
: HTTP Status 404 - /springapp/
: type Status report
: message /springapp/
: description The requested resource is not available.

avatar
z*e
5
你的url map的pattern是*.htm
但是你输入的url是以.html结尾的
当然不会map到了
avatar
z*e
6

springapp
/*.htm

这里是*.htm没发现?
一般来说不要映射到.htm或者.html这些上去
改成.do或者.others,随便你起,但是不要写成静态文件的后缀名
以免引发混淆
avatar
z*e
7
我试了http://localhost:8080/springapp/hello.htm,也同样的错误
而且只要保留了这一段

springapp
org.springframework.web.servlet.DispatcherServletservlet-class>
1


springapp
/*.htm

的话在 Tomcat Web Application Manager 的list applications里面能看到这个/
springapp的running状态是false。
试图在 tomcat web application manager里面start这个application的时候报错FAIL
- Application at context path /springapp could not be started
还是不明白错在哪里

【在 z****e 的大作中提到】
: 你的url map的pattern是*.htm
: 但是你输入的url是以.html结尾的
: 当然不会map到了

avatar
z*e
8
你把spring的jars文件放到tomcat的lib文件夹下去没?

【在 z*********e 的大作中提到】
: 我试了http://localhost:8080/springapp/hello.htm,也同样的错误
: 而且只要保留了这一段
:
: springapp
: org.springframework.web.servlet.DispatcherServlet: servlet-class>
: 1
:

:
: springapp

avatar
z*e
9
我的./springapp/WEB-INF/lib下面有这几个jar
commons-logging-1.1.3.jar
junit.jar
spring-core-4.1.0.RELEASE.jar
spring-webmvc-4.1.0.RELEASE.jar
但是tomcat/lib下面就只有tomcat自带来的jar

【在 z****e 的大作中提到】
: 你把spring的jars文件放到tomcat的lib文件夹下去没?
avatar
l*n
10
你的url pattern 是*.HTM, then it only accepts URL that ends in HTM. usually
static files are handled separately through internalresourceresolver. b.t.w.
, the URL pattern in the tutorial is not recommended.

【在 z*********e 的大作中提到】
: 我的./springapp/WEB-INF/lib下面有这几个jar
: commons-logging-1.1.3.jar
: junit.jar
: spring-core-4.1.0.RELEASE.jar
: spring-webmvc-4.1.0.RELEASE.jar
: 但是tomcat/lib下面就只有tomcat自带来的jar

avatar
z*e
11
我的windows本地机器上没有webserver,就装了个tomcat做测试。不明白为什么会不能
启动这个application

usually
w.

【在 l**********n 的大作中提到】
: 你的url pattern 是*.HTM, then it only accepts URL that ends in HTM. usually
: static files are handled separately through internalresourceresolver. b.t.w.
: , the URL pattern in the tutorial is not recommended.

avatar
l*n
12
build war成功了?

【在 z*********e 的大作中提到】
: 我的windows本地机器上没有webserver,就装了个tomcat做测试。不明白为什么会不能
: 启动这个application
:
: usually
: w.

avatar
z*e
13
war可以不用打包
vert.x也可以不打包就用
当然推荐还是打点包

【在 l**********n 的大作中提到】
: build war成功了?
avatar
z*e
14
你把spring的lib放到tomcat的lib下去试试
另外,你可以下一下eclipse,然后看看有没有tomcat plugin
应该有,jee版本的eclipse应该自动集成了tomcat plugin
然后让eclipse的向导来帮你建sample

【在 z*********e 的大作中提到】
: 我的./springapp/WEB-INF/lib下面有这几个jar
: commons-logging-1.1.3.jar
: junit.jar
: spring-core-4.1.0.RELEASE.jar
: spring-webmvc-4.1.0.RELEASE.jar
: 但是tomcat/lib下面就只有tomcat自带来的jar

avatar
l*n
15
eclipse太难用了,有钱还是无脑上intellij

【在 z****e 的大作中提到】
: 你把spring的lib放到tomcat的lib下去试试
: 另外,你可以下一下eclipse,然后看看有没有tomcat plugin
: 应该有,jee版本的eclipse应该自动集成了tomcat plugin
: 然后让eclipse的向导来帮你建sample

avatar
z*e
16
build成功了,用的是community edition IDEA

【在 l**********n 的大作中提到】
: build war成功了?
avatar
z*e
17
tomcat6/webapps/springapp/WEB-INF/lib下面有这几个jar
commons-logging-1.1.3.jar
junit.jar
spring-core-4.1.0.RELEASE.jar
spring-webmvc-4.1.0.RELEASE.jar
感叹一下spring.io上的tutorial写的好差啊,很多细节没讲,还有不少typo

【在 z****e 的大作中提到】
: 你把spring的lib放到tomcat的lib下去试试
: 另外,你可以下一下eclipse,然后看看有没有tomcat plugin
: 应该有,jee版本的eclipse应该自动集成了tomcat plugin
: 然后让eclipse的向导来帮你建sample

avatar
z*e
18
vmware故意的
如果写得好,就没有掏钱去买他们的服务了

【在 z*********e 的大作中提到】
: tomcat6/webapps/springapp/WEB-INF/lib下面有这几个jar
: commons-logging-1.1.3.jar
: junit.jar
: spring-core-4.1.0.RELEASE.jar
: spring-webmvc-4.1.0.RELEASE.jar
: 感叹一下spring.io上的tutorial写的好差啊,很多细节没讲,还有不少typo

avatar
l*n
19
你确定war deployment成功了吗?intellij定义个run configuration就行了。

【在 z*********e 的大作中提到】
: tomcat6/webapps/springapp/WEB-INF/lib下面有这几个jar
: commons-logging-1.1.3.jar
: junit.jar
: spring-core-4.1.0.RELEASE.jar
: spring-webmvc-4.1.0.RELEASE.jar
: 感叹一下spring.io上的tutorial写的好差啊,很多细节没讲,还有不少typo

avatar
z*e
20
我的tomcat manager里面显示是附件这样的
一定要deploy .war文件吗?我看了其他几个application也没有.war文件。
文件目录
tomcat/webapps/springapp/下面有
META-INF folder
WEB-INF folder
hello.htm
hello.jsp
index.jsp
其中tomcat/webapps/springapp/META-INF folder下面有
MANIFEST.MF
tomcat/webapps/springapp/WEB-INF folder下面有
classes folder
lib folder
springapp-servlet.xml
web.xml
tomcat/webapps/springapp/WEB-INF/classes下面有
tomcat/webapps/springapp/WEB-INF/classes/springapp/web/HelloController.class
tomcat/webapps/springapp/WEB-INF/classes/springapp/web/HelloControllerTests.
class
tomcat/webapps/springapp/WEB-INF/lib下面有
commons-logging-1.1.3.jar
junit.jar
spring-core-4.1.0.RELEASE.jar
spring-webmvc-4.1.0.RELSEASE.jar
我是安装这个教程用ant build/deploy的,应该是成功了吧。还没用过intellij 定义
run configuration,我看看去怎么搞

【在 l**********n 的大作中提到】
: 你确定war deployment成功了吗?intellij定义个run configuration就行了。
avatar
o*g
21
你这还没好使呢?
上面有木有人让你看看TOMCAT_HOME/logs/catalina.out?

【在 z*********e 的大作中提到】
: 我的tomcat manager里面显示是附件这样的
: 一定要deploy .war文件吗?我看了其他几个application也没有.war文件。
: 文件目录
: tomcat/webapps/springapp/下面有
: META-INF folder
: WEB-INF folder
: hello.htm
: hello.jsp
: index.jsp
: 其中tomcat/webapps/springapp/META-INF folder下面有

avatar
z*e
22
update一下,最后把-servlet.xml和web.xml里面的/*.htm都改成/,能work了
相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。