就是这个异常,该怎么解决?
struts-config.xml中的/shop下parameter的值是status
在form表单中也有method="post"
所以不知道是什么原因
struts-config.xml中的/shop下parameter的值是status
在form表单中也有method="post"
所以不知道是什么原因
解决方案 »
- 紧急求救了!愿意把所有分都给了!!谁能帮我修改!!
- Tomcat用eclipse自带的调试工具只能run,不能debug
- 菜鸟100分求助简单问题~~立刻结帖
- 用Struts2.0和Hibernate写了个CURD,有要的留下邮箱
- 大家用什么工具开发网页?
- 各位大侠,如何提取JSP页面中的一些数据
- win98下jsp运行环境变量配置问题(水上裸奔求救)
- 一个关于sql连接的小问题(在线等待)
- 请问<html:button 中如何引用样式表?用class="button1"不行
- 求一段完全遵照MVC模式的代码,已供学习(不要太过高深)
- 让外网的访问局域网的我tomcat,
- isELIgnored为什么不识别啊?
楼主【tujiyue】截止到2008-07-24 11:29:03的历史汇总数据(不包括此帖):
发帖的总数量:15 发帖的总分数:555 每贴平均分数:37
回帖的总数量:53 得分贴总数量:14 回帖的得分率:26%
结贴的总数量:14 结贴的总分数:510
无满意结贴数:3 无满意结贴分:150
未结的帖子数:1 未结的总分数:45
结贴的百分比:93.33 % 结分的百分比:91.89 %
无满意结贴率:21.43 % 无满意结分率:29.41 %
值得尊敬
在form表单中也有method="post" form表单中也有status="post"
那么form表单中就也要有status="方法名"
status="方法名"我肯定在form提前加进去了的,原因还不在这
usershopselectlike就是我的方法名
<action
attribute="shopForm"
input="/errors.jsp"
name="shopForm"
parameter="status"
path="/shop"
scope="request"
type="com.iwtxokhtd.showgoods.struts.action.ShopAction">
....
这个错就是你配置的struts的parameter与你表单提交的值不一样才造成的
贴 代码
<html:form action="shop.do" method="post" onsubmit="return validate(this)">
<font color="gray" size="3"><b>店铺搜索</b></font> <input type="text" name="kw" size="40"/>
<input type="hidden" name="status" value="usershopselectlike"/>
<html:submit value="在所有店铺中搜"></html:submit> </html:form>
struts-config.xml文件:
<action
attribute="shopForm"
input="/errors.jsp"
name="shopForm"
parameter="status"
path="/shop"
scope="request"
type="com.iwtxokhtd.showgoods.struts.action.ShopAction">
....
action:
public ActionForward usershopselectlike(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
// ShopForm sf = (ShopForm) form;// TODO Auto-generated method stub
List all=null;
int currentPage=1;
//每页显示3条
int pageSize=3;
int allRecorders=0;
String keyWord=null;
keyWord=request.getParameter("kw");
try {
String cp="1";
cp=request.getParameter("cp");
if(cp==null||"".equals(cp))
{
cp="1";
}
currentPage=Integer.parseInt(cp);
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
try {
allRecorders=this.ishopdao.getShopCountByLike(keyWord, 1);
all=this.ishopdao.getShopByLike(keyWord, 1, currentPage, pageSize);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
request.setAttribute("currentPage", currentPage);
request.setAttribute("lineSize", pageSize);
request.setAttribute("allRecorders", allRecorders);
request.getSession().setAttribute("all", all);
request.setAttribute("jspUrl", "shop.do");
request.setAttribute("status", "usershopselectlike");
request.setAttribute("keyWord", keyWord);
return mapping.findForward("usershoplist");
}
这里有错误要么写成这样子 "return validateshopForm (this)"
要么不要验证
改一下
action="/shop"
是对应这个JSP吗
<html:form action="shop.do" method="post" onsubmit="return validate(this)">
<font color="gray" size="3"> <b>店铺搜索 </b> </font> <input type="text" name="kw" size="40"/>
<input type="hidden" name="status" value="usershopselectlike"/>
<html:submit value="在所有店铺中搜"> </html:submit> </html:form>
你在action里加个unspecified这个,随便打点什么,断点加在上面。
<form action="shop.do" method="post">
先测试是不是能正常到达action
<form action="shop.do?status=你要调用的action中的方法名称">以上绝对是正解,我的action都是这样写的。
首先你ACTION 中应该有方法吧。。如 ADD ,DEL ,UPD。。你配置的时候设置parameter="status"
所以应该是<html:form action="shop.do?status=add" method="post">
<html:form action="shop.do?status=upd" method="post"> <html:form action="shop.do?status=del" method="post">
</form>
这样的写法我是实验过的,根本到不了我想要招待的方法那里。
DispatchAction中即使没有对应的方法也会到unspecified这个默认的方法里。
你什么都不写就是到这个unspecified里面。
来决定的 如果是Action的话
就直接.do 如果是DispatchAction的话 那你就.do?参数名称=方法名
在struts-congfig.xml配置paameter ="参数名称"
在继承的DispatchAction中 方法名字 就是前面页面中写的方法名
ok!
我也是form 里面加个method =“post”