struts1.3 中 struts-config.xml 中的parameter=“method”属性 然后提交页面,但不能调用add方法 ?
struts-confing.xml文件<form-beans><form-beanname="corseForm"type="com.model.struts.form...
struts-confing.xml文件
<form-beans >
<form-bean name="corseForm" type="com.model.struts.form.CorseForm" />
</form-beans>
<global-exceptions />
<global-forwards />
<action-mappings >
<action attribute="corseForm"
input="/corse.jsp"
name="corseForm"
parameter="method"
path="/corse"
scope="request"
type="com.model.struts.action.CorseAction" />
</action-mappings>
<message-resources parameter="com.model.struts.ApplicationResources" />
</struts-config>
jsp页面
<html>
<head>
<title>添加课程信息</title>
</head>
<body>
<form id="form1" name="form1" method="post" action="corse.do">
<table width="287" border="1" align="center">
<tr>
<td colspan="2" align="center">添加课程信息</td>
</tr>
<tr>
<td width="93">名称</td>
<td width="178"><label>
<input type="text" name="cname" />
</label></td>
</tr>
<tr>
<td>学分</td>
<td><label>
<input type="text" name="ccorse" />
</label></td>
</tr>
<tr>
<td>类型</td>
<td><label>
<input type="text" name="ctype" />
</label></td>
</tr>
<tr>
<td>备注</td>
<td><label>
<input type="text" name="cmass" />
</label></td>
</tr>
<tr>
<td colspan="2" align="center"><label>
<input type="submit" name="Submit" value="提交" />
</label>
<label>
<input type="reset" name="Submit2" value="重置" />
</label></td>
</tr>
</table>
</form>
</body>
</html>
action
public class CorseAction extends Action {
public ActionForward add(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
System.out.println("-------------------------------------");
CorseForm c = (CorseForm) form;// TODO Auto-generated method stub
Corse corse=new Corse(c.getCname(),c.getCcorse(),c.getCtype(),c.getCmass());
CorseDAO cd=new CorseDAO();
cd.save(corse);
return null;
}
}
<form id="form1" name="form1" method="post" action="corse.do?method=add"> 展开
<form-beans >
<form-bean name="corseForm" type="com.model.struts.form.CorseForm" />
</form-beans>
<global-exceptions />
<global-forwards />
<action-mappings >
<action attribute="corseForm"
input="/corse.jsp"
name="corseForm"
parameter="method"
path="/corse"
scope="request"
type="com.model.struts.action.CorseAction" />
</action-mappings>
<message-resources parameter="com.model.struts.ApplicationResources" />
</struts-config>
jsp页面
<html>
<head>
<title>添加课程信息</title>
</head>
<body>
<form id="form1" name="form1" method="post" action="corse.do">
<table width="287" border="1" align="center">
<tr>
<td colspan="2" align="center">添加课程信息</td>
</tr>
<tr>
<td width="93">名称</td>
<td width="178"><label>
<input type="text" name="cname" />
</label></td>
</tr>
<tr>
<td>学分</td>
<td><label>
<input type="text" name="ccorse" />
</label></td>
</tr>
<tr>
<td>类型</td>
<td><label>
<input type="text" name="ctype" />
</label></td>
</tr>
<tr>
<td>备注</td>
<td><label>
<input type="text" name="cmass" />
</label></td>
</tr>
<tr>
<td colspan="2" align="center"><label>
<input type="submit" name="Submit" value="提交" />
</label>
<label>
<input type="reset" name="Submit2" value="重置" />
</label></td>
</tr>
</table>
</form>
</body>
</html>
action
public class CorseAction extends Action {
public ActionForward add(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
System.out.println("-------------------------------------");
CorseForm c = (CorseForm) form;// TODO Auto-generated method stub
Corse corse=new Corse(c.getCname(),c.getCcorse(),c.getCtype(),c.getCmass());
CorseDAO cd=new CorseDAO();
cd.save(corse);
return null;
}
}
<form id="form1" name="form1" method="post" action="corse.do?method=add"> 展开
2个回答
2011-09-21
展开全部
corse=new
追问
那个corse,在那里添加,谢谢
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询