weixin_42304178
2010-03-23 19:29
浏览 201
已采纳

urlrewriter+spring+struts的问题

[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)

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

6条回答 默认 最新

  • qwe_rt 2010-03-24 00:25
    已采纳

    [quote]java.lang.NoSuchMethodException: Action[/index] does not contain specified method (check logs) [/quote]
    查看一下logs,异常有变化!

    点赞 打赏 评论
  • wanghaolovezlq 2010-03-23 19:47

    重定向没有转到指定的url导致

    点赞 打赏 评论
  • qwe_rt 2010-03-23 21:04

    [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

    点赞 打赏 评论
  • qwe_rt 2010-03-23 23:24





    The rule means that requests to /test/status/ will be redirected to /rewrite-status

    the url will be rewritten.



    ^//index/(.*)$

    /index.do?act=$1


    这个行不?

    点赞 打赏 评论
  • qwe_rt 2010-03-23 23:49

    IndexAction把这个action贴出来看看

    点赞 打赏 评论
  • qwe_rt 2010-03-24 00:07

    我想原因出在(.*)上面,".*"是匹配任意的字符,包括[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

    点赞 打赏 评论

相关推荐 更多相似问题