Struts1.2 页面传值到后台 ,DEBUG 里面 form 里面null
这是我的页面表单:<formaction="<%=basePath%>/info.do?method=insertInfo"method="post"name="info...
这是我的 页面 表单:
<form action="<%=basePath %>/info.do?method=insertInfo" method="post" name="infoActionform">
UserID:
<input id="Userid" name="Userid" type="text"/><br>
UserName:
<input id="Username" name="Username" type="text" /><br>
Group:
<input id="Group_" name="Group_" type="text" /><br>
Telephone_No:
<input id="Telephone_No" name="Telephone_No" type="text" /><br>
Status:
<input id="Status" name="Status" type="text" /><br>
Address:
<input id="Address" name="Address" type="text" /><br>
<input type="submit" id="submit" name="submit" value="submit" />
</form>
这是我的struts-config.xml 里面的配置
<struts-config>
<form-beans>
<form-bean name="infoActionform" type="infoActionForm">
</form-bean>
</form-beans>
<action-mappings>
<action path="/info"
type="infoAction"
name="infoActionform"
scope="request">
<forward name="success" path="/success.jsp" />
<forward name="error" path="/err.jsp" />
</action>
</action-mappings>
</struts-config>
这是我ActionForm类:
public class infoActionForm extends ActionForm {
private static final long serialVersionUID = 1L;
private int Userid ;
private String Username;
private String Group_;
private int Telephone_No;
private String Status;
private String Address;
(省略set get 方法)
这是我Action:
public class infoAction extends BaseAction {
public ActionForward insertInfo(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
String path = "error";
infoActionForm infoActionfrom = (infoActionForm)form;
return mapping.findForward(path);
}
获取不到页面输入的值啊。 展开
<form action="<%=basePath %>/info.do?method=insertInfo" method="post" name="infoActionform">
UserID:
<input id="Userid" name="Userid" type="text"/><br>
UserName:
<input id="Username" name="Username" type="text" /><br>
Group:
<input id="Group_" name="Group_" type="text" /><br>
Telephone_No:
<input id="Telephone_No" name="Telephone_No" type="text" /><br>
Status:
<input id="Status" name="Status" type="text" /><br>
Address:
<input id="Address" name="Address" type="text" /><br>
<input type="submit" id="submit" name="submit" value="submit" />
</form>
这是我的struts-config.xml 里面的配置
<struts-config>
<form-beans>
<form-bean name="infoActionform" type="infoActionForm">
</form-bean>
</form-beans>
<action-mappings>
<action path="/info"
type="infoAction"
name="infoActionform"
scope="request">
<forward name="success" path="/success.jsp" />
<forward name="error" path="/err.jsp" />
</action>
</action-mappings>
</struts-config>
这是我ActionForm类:
public class infoActionForm extends ActionForm {
private static final long serialVersionUID = 1L;
private int Userid ;
private String Username;
private String Group_;
private int Telephone_No;
private String Status;
private String Address;
(省略set get 方法)
这是我Action:
public class infoAction extends BaseAction {
public ActionForward insertInfo(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
String path = "error";
infoActionForm infoActionfrom = (infoActionForm)form;
return mapping.findForward(path);
}
获取不到页面输入的值啊。 展开
展开全部
你是用form.getXXX获取不到值么?
你的struts-config.xml有问题,绑定form时,type应该写form的全部路径,而不是一个类名。
<form-bean name="infoActionform" type="infoActionForm">
应该是这么写:
<form-bean name="infoActionform" type="xxxx.xxxx.infoActionForm">
你现在的写法虽然用form.getXXX获取不到值,但是应该可以用request.getPrameter("XXX")获取到
你的struts-config.xml有问题,绑定form时,type应该写form的全部路径,而不是一个类名。
<form-bean name="infoActionform" type="infoActionForm">
应该是这么写:
<form-bean name="infoActionform" type="xxxx.xxxx.infoActionForm">
你现在的写法虽然用form.getXXX获取不到值,但是应该可以用request.getPrameter("XXX")获取到
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询