警告: No configuration found for the specified action: 'loginPerson' in namespace: ''. Form action def

      用struts2写一个登陆小程序,结果tamcat抛了这样的异常:

警告: No configuration found for the specified action: 'loginPerson' in namespace: ''. Form action defaulting to 'action' attribute's literal value.
2012-8-21 13:41:48 com.opensymphony.xwork2.util.logging.jdk.JdkLogger warn
警告: No configuration found for the specified action: 'loginPerson' in namespace: ''. Form action defaulting to 'action' attribute's literal value.

这个问题折腾了半天,有的人还说struts.xml要加ation名称后面要加.action  我整理了两种解决上述警告的方法:

   第一种:采用系统的默认名空间

   struts.xml配置:

  <package name="main" extends="struts-default" >
<global-results>
<result name="login">/login.jsp</result>
</global-results>
  <action name="loginPerson" class="com.helloweenvsfei.struts2.action.LoginAction" >
<result name="success">/success.jsp</result>
</action>
</package>
  </struts>

jsp页面的主要配置:

<body>
    <struts:form  action="loginPerson" method="post" >
    <struts:label value="登陆系统"></struts:label>
    <struts:textfield name="account" label="账号"></struts:textfield>
    <struts:password name="password" label="密码"></struts:password>
    <struts:submit value="登陆"></struts:submit>
    </struts:form>
  </body>

此时jsp页面的此action的路径会被解析为/myApp/loginPerson.action

      第二种: 采用自定义命名空间

       struts.xml配置:

       <package name="main" extends="struts-default" namespace="/hello">
          <global-results>
<result name="login">/login.jsp</result>
          </global-results>
  <action name="loginPerson" class="com.helloweenvsfei.struts2.action.LoginAction" >
<result name="success">/success.jsp</result>
</action>
</package>

        jsp页面的配置:

         <body>
    <struts:form  action="loginPerson" method="post" namespace="/hello">
    <struts:label value="登陆系统"></struts:label>
    <struts:textfield name="account" label="账号"></struts:textfield>
    <struts:password name="password" label="密码"></struts:password>
    <struts:submit value="登陆"></struts:submit>
    </struts:form>
      </body>

此时jsp页面的action路径会被解析为/myApp/hello/loginPerson

另外不管是哪种配置的struts.xml中的action的名称会被struts自动追加.action后缀,所以不管是那种配置方法都不应该将action的名称配置为***.action

  • 3
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值