貌似是泛类型错误,具体的真的不知道是怎么回事
goodsAction
package sale.action;
import java.sql.SQLException;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import org.apache.struts2.ServletActionContext;
import sale.domain.Goods;
import sale.service.GoodsFacade;
import sale.service.GoodsFacadeImpl;
public class GoodsAction {
private GoodsFacade goodsFacade;
Goods goods;
private int goodsId;
private List<Goods> list;
public GoodsAction() {
goodsFacade = new GoodsFacadeImpl();
}
public GoodsFacade getGFacade() {
return goodsFacade;
}
public void setGFacade(GoodsFacade facade) {
goodsFacade = facade;
}
public Goods getGoods() {
return goods;
}
public void setGoods(Goods goods) {
this.goods = goods;
}
public int getGoodsId() {
return goodsId;
}
public void setGoodsId(int goodsId) {
this.goodsId = goodsId;
}
public List<Goods> getList() {
return list;
}
public void setList(List<Goods> list) {
this.list = list;
}
public String addGoods() throws SQLException{
Goods goods=getGoods();
try{
goodsFacade.addGoods(goods);
setGoods(goods);
return"goodsSuccess";
}catch(Exception e){
e.printStackTrace();
return"goodsError";
}
}
}
---------------------------------------------
add.jsp页面
<%@ page language="java" import="java.util.*" pageEncoding="GB2312"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<s:head theme="ajax"/>
</head>
<body>
<div align="center">
<center>
<%-- 请求regValidate这个Action来进行处理,并且设置执行客户端校验--%>
<s:form action="goodsAction" method="addGoods" validate="false">
<%--加入token标签,避免重复提交--%>
<s:token />
<%--文本框标签,其中name属性指定传值参数,label属性指定该文本框标签名--%>
<s:textfield name="goods.name" label="商品名称" />
<s:textfield name="goods.warehouseId" label="仓库号" />
<s:textfield name="goods.description" label="商品描述" />
<s:textfield name="goods.number" label="数量" />
<s:textfield name="goods.cost" label="成本价" />
<s:submit value="确定" />
<s:reset value="重置" />
</s:form>
</center>
<br>
</div>
</body>
</html>
---------------------------------------------
goodADOIml
package sale.persistence;
import java.sql.SQLException;
import java.util.Date;
import java.sql.*;
import sale.domain.Goods;
import sale.util.DBConnection;
import sale.util.Time;
public class GoodsDAOImpl implements GoodsDAO {
Connection conn=null;
Time now=new Time();
Statement st=null;
PreparedStatement psmt1=null;