does not contain handler parameter named 'method'. This may be caused by whitespace in the label text.异常及其解决方案

来源:互联网 发布:linux怎么查看端口号 编辑:程序博客网 时间:2024/05/16 06:19

Dispatch时产生了这个异常:does not contain handler parameter named ‘method’ This may be caused by whitespace in the label text

DispatchActio E org.apache.struts.actions.DispatchAction  Request[/messageAction] does not contain handler parameter named 'method'.  This may be caused by whitespace in the label text.
出现这个异常的原因是,jsp页面上配置了如下的句子:
<html:hidden property=“method“ value....>

这是以前的一篇文章,今天发生的异常和这个有相似之处:
[Request[/requisitionAction] does not contain handler parameter named &#39;act&#39;.  This may be caused by whitespace in the label text.]:javax.servlet.ServletException: Request[/requisitionAction] does not contain handler parameter named 'act'.  This may be caused by whitespace in the label text.

经我分析,原因有以下几点,因为我用了lookupdispatch,所以就在这方面谈谈:
原因1:类似下面的错误用法:
             <html:button property="act" styleClass="buttons" onclick="completeWorkItem">
              <fmt:message key="CreateApplyForm.addLight"/>
            </html:button>
js如下:
function completeWorkItem(){
  var userForm = document.forms[0];
  if(!dataCheck()) return false;
  if( window.confirm("")){
     addDSOXML(); 
     addLight(); 
     userForm.submit(); return true;
  }
  return false;
}

因为act=value再映射到key,由key 再映射到方法名,在jsp页面中,除过提交(submit),别的只能通过包含act=value(act是struts里配的parameter)的url来实现,但是在提交中,可以这么做:
                 <html:submit property="act" styleClass="buttons" onclick="completeWorkItem();">
                  <fmt:message key="AttachBizForm.submit"/>
                </html:submit>
也就是说,只要将property指定为act把value在资源文件中按照上述映射即可,不用去指定act=value
原创粉丝点击