[code="xml"]
The rule means that requests to /test/status/ will be redirected to /rewrite-status
the url will be rewritten.
/index/(.*)
/index.do?act=$1
[/code]
访问http://localhost:8080/project/index/login抛异常
ERROR [org.apache.struts.actions.DispatchAction] - Action[/index] does not contain method named 'undefined'
java.lang.NoSuchMethodException: com.soft.index.action.IndexAction.undefined(org.apache.struts.action.ActionMapping, org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
at java.lang.Class.getMethod(Class.java:1581)
......
ARN [org.apache.struts.action.RequestProcessor] - Unhandled Exception thrown: class java.lang.NoSuchMethodException
[19:22:37.961] javax.servlet.ServletException: java.lang.NoSuchMethodException: Action[/index] does not contain specified method (check logs)
[quote]java.lang.NoSuchMethodException: Action[/index] does not contain specified method (check logs) [/quote]
查看一下logs,异常有变化!
重定向没有转到指定的url导致
[quote]Action[/index] does not contain method named 'undefined'
[/quote]已经转向了index这个action,但是根据提示:方法名"undefined",如果你没有这个方法。那么配置文件出错了或者action。
举个例子。
[code="java"]
@Override
public String execute() {
///处理
return SUCCESS;
} [/code]
然后相应的struts.xml配置文件是这样的:
[code="xml"]< package name ="ActionDemo" extends ="struts-default" >
< action name ="HelloWorld" class ="tutorial.HelloWorld" >
< result > /HelloWorld.jsp </ result >
</ action >
</ package > [/code]
参考:
urlrewriter:
http://blog.csdn.net/chenpy/archive/2009/05/06/4155161.aspx
struts2:http://blog.csdn.net/jawsy/archive/2007/03/14/1529223.aspx
The rule means that requests to /test/status/ will be redirected to /rewrite-status
the url will be rewritten.
^//index/(.*)$
/index.do?act=$1
这个行不?
IndexAction把这个action贴出来看看
我想原因出在(.*)上面,".*"是匹配任意的字符,包括[color=red]空白[/color],空白的影响可能性大。
换一个排除空白的可能性。
The rule means that requests to /test/status/ will be redirected to /rewrite-status
the url will be rewritten.
/index/(\w*)
/index.do?act=$1