首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > J2SE开发 >

在form action中怎么直接调用servlet

2012-01-07 
在form action中如何直接调用servlet以下hello为servlet,但在浏览器中运行提交时出现Status reportmessage

在form action中如何直接调用servlet
以下hello为servlet,但在浏览器中运行提交时出现
Status report

message /axis/helloworld

description The requested resource (/axis/helloworld) is not available.

代码如下:

<form action="helloworld" method="POST" name="form1">
  请输入文件名:
  <label>
  <input type="text" name="textfield" />
  </label>
  <input name="submit" type="submit" value="显示" />
  </form>

请问是什么原因?

[解决办法]
servlet很容易碰到路径的问题,你要看下web.xml里怎么配置路径的.改成这样试下action="/你的项目名/helloworld"
[解决办法]
<servlet-mapping> 
<servlet-name> helloworld </servlet-name> 
<url-pattern> /hello </url-pattern> 
</servlet-mapping>
既然你配置的是/hello,那为什么你访问要用helloworld呢?
[解决办法]
<form action="hello" method="POST" name="form1"> 
应该就没问题了。
[解决办法]
呵呵
/hello != /helloworld
[解决办法]
全改成Hello吧
[解决办法]
action="<%=request.getContextPath()%>/hello"
[解决办法]
action="/你的项目名/hello
[解决办法]
10楼的应该可以了,就是我上面写的action="/你的项目名/helloworld",开始我以为你web.xml里配置的是helloworld.现在把它改成action="/axis/hello"就可以了.
[解决办法]
<form action="../helloworld" method="POST" name="form1">
[解决办法]
action="" ""里面要跟跳转的页面或地址,直接写文件名不对地...帮顶了

热点排行