关于网友提出的“ 在execute()为什么得到的到form中的值是null”问题疑问,本网通过在网上对“ 在execute()为什么得到的到form中的值是null”有关的相关答案进行了整理,供用户进行参考,详细问题解答如下:
问题: 在execute()为什么得到的到form中的值是null
描述: 我在用struts写程序时,在execute()方法中得到的form值是null,这是为什么
我的action程序是这样写的
public class ZhengzhiAction extends Action {
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
ZhengzhiForm zhengzhiForm = (ZhengzhiForm) form;
String type=(String)zhengzhiForm.getZhengzhi();
System.out.println("type:" +type);
在这里我打印出的type值是null,这个是为什么,要怎样才能的到 type的值
我在提交的jsp文件中是这样写的
<%@ page language="java" c/html;charset=gbk"%>
">政治
">
解决方案1: <%@ page language="java" c/html;charset=gbk"%>
">政治
">
你的zhengzhiForm有属性zhengzhi,传的parameter名字和actionForm的属性名一致才能拿到
以上介绍了“ 在execute()为什么得到的到form中的值是null”的问题解答,希望对有需要的网友有所帮助。
本文网址链接:http://www.codes51.com/itwd/3403788.html