用struts2,页面的数据由pojo来收集用在相应的action类中
问题:
pojo的属性有一个引用类型的对象,这是在pojo在做收集页面数据的时候,就会有nullPointException,
这是怎么回事,如果说把那个引用类型的去掉,就不会有问题,百思不得其解....
问题:
pojo的属性有一个引用类型的对象,这是在pojo在做收集页面数据的时候,就会有nullPointException,
这是怎么回事,如果说把那个引用类型的去掉,就不会有问题,百思不得其解....
解决方案 »
- 关于html:link
- 请问有java开源的B2B网站吗?推荐下。最好有数据库的
- 关于动态html表单,struts的actionform应该如何设置
- 请问activemq消息发送机制有连接超时这种情况发生吗?
- 单独测试dao中的方法
- 哪位大哥哥 给饿发一份中文版的api 谢谢了
- java邮件发送问题再线等,解决马上给分
- 路径问题 ClassLoader.getSystemResourceAsStream() Javapath CLASSPATH InputStream
- 关于opds的问题,求高手解答。
- tomcat虚拟主机的配置=====================高分求解
- axis2插件生成aar的问题
- struts2源码的问题
private Integer financialAccNo;
private Integer fundNo;
private Integer quantity;
private Double price;
private Fund funds; public FundAccount()
{
} /** full constructor */
public FundAccount(Integer financialAccNo,
Integer quantity, Double price,Integer fundNo) {
this.financialAccNo = financialAccNo;
this.fundNo = fundNo;
this.quantity = quantity;
this.price = price;
} // Property accessors public Integer getFundAccNo() {
return this.fundAccNo;
} public void setFundAccNo(Integer fundAccNo) {
this.fundAccNo = fundAccNo;
} public Integer getFinancialAccNo() {
return this.financialAccNo;
} public void setFinancialAccNo(Integer financialAccNo) {
this.financialAccNo = financialAccNo;
} public Integer getFundNo() {
return this.fundNo;
} public void setFundNo(Integer fundNo) {
this.fundNo = fundNo;
} public Integer getQuantity() {
return this.quantity;
} public void setQuantity(Integer quantity) {
this.quantity = quantity;
} public Double getPrice() {
return this.price;
} public void setPrice(Double price) {
this.price = price;
} public Fund getFunds() {
return funds;
} public void setFunds(Fund funds) {
this.funds = funds;
}去掉public void setFunds(Fund funds) {
this.funds = funds;
}
就不会有问题,但是这个不能去掉,其它代码还有用到这个
如果不是,你可以试下
this.funds = funds;
}
就不会有问题,但是这个不能去掉,其它代码还有用到这个
<table width="407" height="227" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#F2F2F2" bordercolor="#E6E6E6">
<s:select name="fundAccount.fundNo" list="#request.listFund" listKey="fundNo" listValue="fundName" label="上市基金"/>
<s:textfield name="fundAccount.quantity" label="购买数量"/>
<s:textfield name="fundAccount.price" label="当前价格"/>
<s:textfield name="financialAccount.accountNo" label="资金帐户"/>
<s:textfield name="financialAccount.password" label="资金帐户密码"/>
<s:submit value="购买" /><s:reset value="重置"/>
</table>
</s:form>
以我的想法,你的POJO不用改变,二Form和Action写成如下姓石应该没有问题package org.spring.hibernate;public class FundAccountAction extends ActionSupport {
private Integer fundAccNo;
private Integer financialAccNo;
private Integer fundNo;
private Integer quantity;
private Double price;
public String insert()throws Exception{
FundAccount fa = new FundAccount();
fa.setFundAccNo = fundAccNo;
.......
}
public Integer getFundAccNo() {
return fundAccNo;
}
public void setFundAccNo(Integer fundAccNo) {
this.fundAccNo = fundAccNo;
}
public Integer getFinancialAccNo() {
return financialAccNo;
}
public void setFinancialAccNo(Integer financialAccNo) {
this.financialAccNo = financialAccNo;
}
public Integer getFundNo() {
return fundNo;
}
public void setFundNo(Integer fundNo) {
this.fundNo = fundNo;
}
public Integer getQuantity() {
return quantity;
}
public void setQuantity(Integer quantity) {
this.quantity = quantity;
}
public Double getPrice() {
return price;
}
public void setPrice(Double price) {
this.price = price;
}
}<s:form action="fundAccount!insert" method="post">
<table width="407" height="227" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#F2F2F2" bordercolor="#E6E6E6">
<s:select name="fundNo" list="#request.listFund" listKey="fundNo" listValue="fundName" label="上市基金"/>
<s:textfield name="quantity" label="购买数量"/>
<s:textfield name="price" label="当前价格"/>
<s:textfield name="accountNo" label="资金帐户"/>
<s:textfield name="password" label="资金帐户密码"/>
<s:submit value="购买" /> <s:reset value="重置"/> </table>
</s:form>