报404,怎么回事啊,拜托各位了。
请求路径:http://localhost:8888/one/add?add
ACTION代码:
public class AddAction extends ActionSupport{
public String add(){
System.out.println("=====addActon======");
return “success”;
}
}
STRUTS配置文件:
<struts>
<package name="default" extends="struts-default" namespace="/">
<action name="add" class="action.AddAction" method="add">
<result name="success">/webRoot/regist.jsp</result>
</action>
</package>
</struts>
另附上web.xml代码如下:
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
[最优解释]
为什么 你的错误 会提示 会找不到add. 怎么多个.
[其他解释]
你这是使用的默认的命名空间,用http://localhost:8888/one/add.action试试
项目中使用强烈建议给命名空间命名<package name="test" extends="struts-default" namespace="/test">
路径就为:http://localhost:8888/one/test/add.action
[其他解释]
http://localhost:8888/one/add?add
你这个请求路径有点问题吧, 如果你是想用动态方法调用也应该是用感叹号吧.
你这个action又没有接收请求参数, 你传个name为add的参数又不给值实在不懂是什么意思
[其他解释]
请求路径:http://localhost:8888/one/add?add
这个one 是什么?没看到 配置文件有用到呀 add?add 传值add?
改成http://localhost:8888/add 看看如何? 还是不行 就把错误贴出来
[其他解释]
楼上大哥你好,one是项目的名称,add?add代表调用AddAction里面的add方法
改成http://localhost:8888/one后运行,显示index.jsp页面
改成http://localhost:8888/add后运行,浏览器报错如下:
HTTP Status 404 - /add
type Status report
message /add
description The requested resource (/add) is not available.
Apache Tomcat/6.0.18
附:控制台没有任何反应
[其他解释]
http://localhost:8888/add.action 哈哈 忘了
[其他解释]
description The requested resource (/one/add.Action) is not available.
[其他解释]
http://localhost:8888/one/add.action
今天怎么了 总写错 我要休息休息了
[其他解释]
改了啊,可还是没效果,是不是web。xml上出了点问题啊,呵呵
[其他解释]
<url-pattern>/*</url-pattern>------------- <url-pattern>*</url-pattern>
[其他解释]
web.xml
<filter>
<filter-name>struts2</filter-name>
<filter-class>
org.apache.struts2.dispatcher.FilterDispatcher
</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>REQUEST</dispatcher>
<dispatcher>FORWARD</dispatcher>
</filter-mapping>
不应该呀
[其他解释]
输入请求路径http://localhost:8888/one/add.action后运行如下:
严重: Could not find action or result
There is no Action mapped for action name add. - [unknown location
[其他解释]
呵呵,已经解决了,地址应该是这样的
http://localhost:8888/one/add.action,要加点Action,谢谢你们了,给你们分
[其他解释]
我没有分的说~