注解配置struts2,总是失败

错误提示HTTP Status 404 - There is no Action mapped for namespace [/] and action name [enter] associated with context path [/test1].

@Action(value="enter",
results={@Result(name="success",location="/success.jsp"),
@Result(name="login",location="/index.jsp")})
public class Enter extends ActionSupport
{
能回答出来的再加20分

第1个回答  2014-03-15
你把这个Action配错地方了!Enter是一个Action类,而非Action方法。应该这样配:
public class Enter extends ActionSupport{

/**

* 具体的Action方法
*/
@Action(value = "enter" results={})
public String enter()

{

}

}追问

那个enter是我随便写的,我想访问的是Enter类不是想要它的访问方法

追答

但你的报错的意思是enter 这个Action方法没有找到!

追问

是啊,我想访问的是Enter类,所以随便写value=“enter”了,难道想要访问Enter类不能这么写吗,那要怎样写啊

追答

恩,我们现在都是在struts.xml中配置的,使用注解这种形式的还不是很多,不能提供啥帮助了。

追问

如果用xml配置我也很熟啊,不是说现在都流行注解配置吗,所以我才开始学习注解配置啊

追答

哦!

第2个回答  2015-03-31
如果配置没问题,自己写的Action继承ActionSupport类
相似回答