您的位置:首页 > 编程语言 > Java开发

实验室网站所遇技术(三) struts1.2.9的通配符配置

2012-08-08 21:31 369 查看
今天为了简化struts的配置,研究通配符,发现一个有意思的地方。

我的struts版本是1.2.9

看配置文件

<action path="/regist_*"
name="registForm"
type="com.lihua.actions.RegistAction"
parameter="{1}">
<forward name="success" path="/index.jsp"/>
</action>


前台jsp页面的请求不管是这样

<form action="regist_add.do" method="post">


还是这样

<form action="regist_add.do?method=add" method="post">


都是一个错误

严重: Request[/regist_add] does not contain handler parameter named 'add'.  This may be caused by whitespace in the label text.
2012-8-8 21:24:51 org.apache.struts.action.RequestProcessor processException
警告: Unhandled Exception thrown: class javax.servlet.ServletException
2012-8-8 21:24:51 org.apache.catalina.core.StandardWrapperValve invoke
严重: Servlet.service() for servlet action threw exception
javax.servlet.ServletException: Request[/regist_add] does not contain handler parameter named 'add'.  This may be caused by whitespace in the label text.


我就很纠结了,这是参照网上的博客改写的。

后来不断尝试发现这样写就可以

<action path="/regist_*"
name="registForm"
type="com.lihua.actions.RegistAction"
parameter="method">
  <forward name="success" path="/index.jsp"/>
</action>


前端访问页面的form是

<form action="regist_add.do?method=add" method="post">


问题解决了,可以批量写配置了。

但是那个错误问题还是没弄懂?求解?
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: