日期:2014-05-19  浏览次数:20575 次

报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   哈哈 忘了
------其他解决方案--------------------
引用:
你这是使用的默认的命名空间,用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.Action后浏览器报错如下:
description The requested resource (/one/add.Action) is not available.


------其他解决方案--------------------
http://localhost:8888/one/add.action   
今天怎么了  总写错  我要休息休息了
------其他解决方案--------------------
引用:
http://localhost:8888/one/add.action   
今天怎么了  总写错  我要休息休息了
改了啊,可还是没效果,是不是web。xml上出了点问题啊,呵呵
------其他解决方案--------------------
<url-pattern>/*</url-pattern>-------------     <url-pattern>*</url-pattern>