用struts2,页面的数据由pojo来收集用在相应的action类中
问题:
pojo的属性有一个引用类型的对象,这是在pojo在做收集页面数据的时候,就会有nullPointException,
这是怎么回事,如果说把那个引用类型的去掉,就不会有问题,百思不得其解....
问题:
pojo的属性有一个引用类型的对象,这是在pojo在做收集页面数据的时候,就会有nullPointException,
这是怎么回事,如果说把那个引用类型的去掉,就不会有问题,百思不得其解....
解决方案 »
- 自学EJB,看什么书好
- struts1下载后台报clientAbortException,文件下载正确
- hibernate类型问题 java.lang.IllegalArgumentException: object is not an instance of
- 启动weblogic报错。急。在线等。
- struts在什么情况下会跳转到空也面上去啊?一片空白。不知道什么原因
- 谁有比较好的免费的jsp开源论坛源码,适合二次开发的
- Tomcat No Java Virtual Machine found的问题
- JNDI的问题
- 专业英语问题(4)--Bandwidth Throttling
- 谁有Eclipse中文版,100分呀
- 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>