站内搜索: 请输入搜索关键词

当前页面: 开发资料首页JSP 专题JSP调用SERVLET 问题。反复调试了很长时间,不得其解

JSP调用SERVLET 问题。反复调试了很长时间,不得其解

摘要: JSP调用SERVLET 问题。反复调试了很长时间,不得其解


我的调用SERVLET的JSP:webprj/WebContent/default.jsp
我的SERVLET的路径:webprj/WebContent/WEB-INF/classes/com/study/sservlet/SimpleCounter.class

我的web.xml:webprj/WebContent/WEB-INF/web.xml
servlet配置:

SimpleCount
com.study.sservlet.SimpleCounter


SimpleCount
/SimpleCounter.go


default.jsp里面调用servlet:
<form action="/SimpleCounter.go" method="post" onsubmit="submitt()" name="form1">

但是在调用的时候出现在地址篮:http://localhost:8081/SimpleCounter.go 调用失败
如果我在地址蓝输入:http://localhost:8081/webprj/SimpleCounter.go 调用成功

帮忙看看这样配置调用SERVLET有问题吗 ?
为什么不能直接调用SERVLET成功??
反复测试的情况:
如果我把default.jsp的配置改成:<form action="/webprj/SimpleCounter.go" method="post"
onsubmit="submitt()" name="form1">
地址蓝出现:http://localhost:8081/webprj/SimpleCounter.go 调用失败如果我改成
http://localhost:8081/webprj//SimpleCounter.go 回车刷新则成功

我的开发环境是eclipse+lobmoz+jboss




耶!!沙发

楼主我支持你
-----------------
松自萧萧云自飘
风中独酌亦逍遥
抚却凡愁与尘念
琴韵未解恨已销


server.xml

path="/"
privileged="true"
reloadable="true"
>


Servlet的路径问题
在工程目录webprj下应该有个src目录,在该目录下添加名为com.study.sservlet的包
然后把你的Servlet的.java文件放在这个包内



我把ECLIPSE+LOMBOZ+JBOSS, 在测试环境下,调试。 改着JBOSS的SERVER 。XML 路径不成功


Servlet的路径问题
在工程目录webprj下应该有个src目录,在该目录下添加名为com.study.sservlet的包
然后把你的Servlet的.java文件放在这个包内

我是这样发布的。


光碰到些奇怪的问题了


UP 有意思。


<form action="/SimpleCounter.go" method="post" onsubmit="submitt()" name="form1">
这样写是有错误的,/代表tomcat根目录而不是你的网络应用webprj的根路径,有两种方法可行:
1.
<form action="/webprj/SimpleCounter.go" method="post" onsubmit="submitt()" name="form1">
2.
<form action="../../SimpleCounter.go" method="post" onsubmit="submitt()" name="form1">


调用SERVLET改成:
<form action="SimpleCounter.go" method="post" onsubmit="submitt()" name="form1">
会出现这样的地址:http://localhost:8081/webprj/SimpleCounter.go

包错

但是如果把地址改成:
会出现这样的地址:http://localhost:8081/webprj//SimpleCounter.go
在simplecounter.go前加两个/ 回车刷新就成功
太奇怪了


改成:
<form action="/webprj/SimpleCounter.go" method="post" onsubmit="submitt()" name="form1">

地址栏出现:http://localhost:8081/webprj/SimpleCounter.go
报这样的错:type Status report

message HTTP method POST is not supported by this URL

description The specified HTTP method is not allowed for the requested resource (HTTP method POST is not supported by this URL).






改成:
<form action="/webprj/SimpleCounter.go" method="post" onsubmit="submitt()" name="form1">

地址栏出现:http://localhost:8081/webprj/SimpleCounter.go
报这样的错:type Status report

message HTTP method POST is not supported by this URL

description The specified HTTP method is not allowed for the requested resource (HTTP method POST is not supported by this URL).

这种情况下在地址栏改成:http://localhost:8081/webprj//SimpleCounter.go 也就是在SIMPLECOUNTER。GO 前加两个/ ,回车刷新调用成功。 为什么会这样?



↑返回目录
前一篇: JSP文件中用-lt
后一篇: 权限验证问题