cxc3980 2009-03-05 14:09
浏览 257
已采纳

请教问题attempt to create saveOrUpdate event with null

Action中得不到jsp页面表单中的值,大家帮忙看一下哪里错了。
jsp页面:


<%@ page language="java" contentType="text/html; charset=utf-8"
pageEncoding="utf-8"%>
<%@ taglib uri="/struts-tags" prefix="s" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Insert title here</title>
</head>
<body>
<s:form action="insert" namespace="/hwinfo">
<s:textfield label="主板" name="hwinfo.motherboard" />
<s:textfield label="芯片" name="hwinfo.chipset" />
<s:submit value="提交" />
</s:form>
</body>
</html>

XML文件:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
" -//Apache Software Foundation//DTD Struts Configuration 2.0//EN "
" http://struts.apache.org/dtds/struts-2.0.dtd " >

<struts>
<constant name ="struts.devMode" value = "true" />
<constant name = "struts.configuration.xml.reload" value = "true" />
<constant name = "struts.action.extension" value = "action" />

&lt;package name = "default" extends = "struts-default"&gt; 
    &lt;action name = "admincp"&gt; 
        &lt;result&gt;/admin/login.jsp&lt;/result&gt; 
    &lt;/action&gt;       
&lt;/package&gt; 

<package name = "hwinfo" extends = "struts-default" namespace = "/hwinfo">
<action name="insert" class="hwInfoAction" method="insertHwinfo">
<result name="success">/hwinfo/hardwareinfo.jsp</result>
<result name="input">index.jsp</result>
</action>

</package>
</struts>


Action:

public class HwInfoAction extends ActionSupport{
/**
*
*/
private static final long serialVersionUID = 1L;
private int hwid;
private String motherboard;
private String chipset;

private HwInfo hwinfo;
private HwInfoDao hwInfoDao;
public void setHwid(int hwid){
    this.hwid=hwid;
}
public int getHwid(){
    return hwid;
}

public void setMotherboard(String motherboard){
    this.motherboard=motherboard;
}
public String getMotherboard(){
    return motherboard;
}

public void setChipset(String chipset ){
    this.chipset=chipset;
}

 public String getChipset(){
        return chipset;
    }

public void setHwInfo(HwInfo hwinfo){
    this.hwinfo=hwinfo;
}
public HwInfo getHwInfo(){
    return hwinfo;
}
public void setHwInfoDao(HwInfoDao hwInfoDao){
    this.hwInfoDao=hwInfoDao;
}
public HwInfoDao getHwInfoDao(){
    return hwInfoDao;
}

public String execute(){
    return "success";
}

public String insertHwinfo(){

    if(hwInfoDao.insertHwinfo(hwinfo))
        return "seccess";
    else
        return "false";
}

}


实在找不出问题了,大家帮忙看看吧!
问题补充:
在action类里面看hwinfo的值,始终是Null,得不到 表单传递过来的值
  • 写回答

3条回答 默认 最新

      报告相同问题?

      相关推荐 更多相似问题

      悬赏问题

      • ¥15 如何增加获取淘宝的数据订单
      • ¥15 fluent计算后处理中如何把质量分数和摩尔分数转化为体积分数
      • ¥20 asn1c编码问题,懂asn1的人很简单
      • ¥60 在排球比赛中,排球落于界限上时,人工判断存在一定的主观因素。利用图像处理的方法来计算排球落点相对界限中心位置,判断结果。
      • ¥15 使用vs2019开发的动态链路库在win7环境下使用有问题
      • ¥30 quartus prime画电路图,要发源文件和电路图每个模块批注,源程序和仿真结果
      • ¥15 MFC滚动条如何正确使用
      • ¥15 缓冲区算法求面积,基于文献
      • ¥50 电路PCB原理图设计AD19
      • ¥15 openstack 云平台搭建 创建实例错误