ClientGoodsDAO
--------------
package com.clientgoods.dao;
import java.sql.*;import javax.sql.DataSource;
import com.clientgoods.JavaBeans.*;
public class ClientGoodsDAO {
public ClientGoodsDAO() {
} public ClientGoodsModel insert(ClientGoodsModel model) throws Exception{
String sql = "insert into tClientGoods(clientCode,goodCode,price,startDate,endDate,goodState,re)"
+" values(?,?,?,?,?,?,?)";
Connection con = null;
PreparedStatement stmt = null;
try{
DataSource dataSource = null;
con = dataSource.getConnection();
stmt = con.prepareStatement(sql);
stmt.setString(1,model.getClientCode());
stmt.setString(2,model.getGoodCode());
stmt.setString(3,model.getPrice());
stmt.setString(4,model.getStartDate());
stmt.setString(5,model.getEndDate());
stmt.setString(6, model.getGoodState());
stmt.setString(7, model.getRe());
stmt.executeUpdate(sql);
con.commit();
}catch(Exception e){
con.rollback();
throw e;
}
finally{
stmt.close();
con.close();
}
return model;
} public void update(ClientGoodsModel model) throws Exception{
String sql = "update tClientGoods set clientCode='"+model.getClientCode()+"',goodCode='"+model.getGoodCode()+"',price='"+model.getPrice()+"',startDate='"+model.getStartDate()
+"',endDate='"+model.getEndDate()+"',goodState='"+model.getGoodState()+"',re='"+model.getRe()+"'" +" where clientCode='"+model.getClientCode()+"'";
Connection con = null;
Statement stmt = null;
try{
DataSource dataSource = null;
con = dataSource.getConnection();
stmt =con.createStatement();
stmt.executeUpdate(sql);
con.commit();
}catch(Exception e){
System.out.println("添加客户商品!");
}
finally{
stmt.close();
con.close();
}
} /* public void delete(String clientCode) throws Exception{
String sql = "delete from tClientCode where clientCode='" + clientCode +"'";
Connection con = null;
PreparedStatement stmt = null;
try
{
con = (Connection) DbPool.getConnection();
stmt = ((java.sql.Connection) con).prepareStatement(sql);
stmt.executeUpdate();
((java.sql.Connection) con).commit();
}
catch(Exception e)
{
throw e;
}
finally
{
DbPool.closeStatement(stmt);
DbPool.closeConnection((java.sql.Connection) con);
}
}*/ public ClientGoodsModel queryClientGoodsByClientCode(String clientCode)
throws Exception{
ClientGoodsModel model = null;
String sql = "select clientCode,goodCode,price,startDate,endDate,goodState,re from tClientGoods";
sql += " where clientCode = '"+clientCode+"'";
ResultSet rs = null;
Connection con = null;
Statement statement = null;
try{
DataSource dataSource = null;
con = dataSource.getConnection();
statement =con.createStatement();
rs = statement.executeQuery(sql);
while(rs.next()){
model = new ClientGoodsModel();
model.setClientCode(rs.getString("clientCode").trim());
model.setGoodCode(rs.getString("goodCode").trim());
model.setPrice(rs.getString("price").trim());
model.setStartDate(rs.getString("startDate"));
model.setEndDate(rs.getString("endDate"));
model.setGoodState(rs.getString("goodState").trim());
model.setRe(rs.getString("re").trim());
}
}catch(Exception e){
throw e;
}
finally{
rs.close();
statement.close();
con.close();
}
return model;
}
}
----------------------------------------------------------------------------------------
ClientGoodsProxy
------------------
package com.clientgoods.JavaBeans;import com.clientgoods.JavaBeans.ClientGoodsModel;
import com.clientgoods.dao.ClientGoodsDAO;public class ClientGoodsProxy {
ClientGoodsDAO dao = null;
public ClientGoodsProxy(){
dao = new ClientGoodsDAO();
}
public ClientGoodsModel queryClientGoodsByClientCode(String clientCode) throws Exception{
return dao.queryClientGoodsByClientCode(clientCode);
} /*public ArrayList queryClientGoods(ClientGoodsModel model,Pager pager) throws Exception{
ArrayList lList = new ArrayList();
lList = dao.query(model);
return Utility.generatePager(lList,pager);
} public ArrayList queryClientGoods(ClientGoodsModel model) throws Exception{
return dao.query(model);
} public ClientGoodsModel queryClientGoods(String clientCode) throws Exception{
return dao.queryClientGoods(clientCode);
}*/ public void insertClientGoods(ClientGoodsModel model) throws Exception{
dao.insert(model);
} public void updateClientGoods(ClientGoodsModel model) throws Exception{
dao.update(model);
} /* public void deleteClientGoods(String clientCode) throws Exception{
dao.delete(clientCode);
}*/
}
--------------
package com.clientgoods.dao;
import java.sql.*;import javax.sql.DataSource;
import com.clientgoods.JavaBeans.*;
public class ClientGoodsDAO {
public ClientGoodsDAO() {
} public ClientGoodsModel insert(ClientGoodsModel model) throws Exception{
String sql = "insert into tClientGoods(clientCode,goodCode,price,startDate,endDate,goodState,re)"
+" values(?,?,?,?,?,?,?)";
Connection con = null;
PreparedStatement stmt = null;
try{
DataSource dataSource = null;
con = dataSource.getConnection();
stmt = con.prepareStatement(sql);
stmt.setString(1,model.getClientCode());
stmt.setString(2,model.getGoodCode());
stmt.setString(3,model.getPrice());
stmt.setString(4,model.getStartDate());
stmt.setString(5,model.getEndDate());
stmt.setString(6, model.getGoodState());
stmt.setString(7, model.getRe());
stmt.executeUpdate(sql);
con.commit();
}catch(Exception e){
con.rollback();
throw e;
}
finally{
stmt.close();
con.close();
}
return model;
} public void update(ClientGoodsModel model) throws Exception{
String sql = "update tClientGoods set clientCode='"+model.getClientCode()+"',goodCode='"+model.getGoodCode()+"',price='"+model.getPrice()+"',startDate='"+model.getStartDate()
+"',endDate='"+model.getEndDate()+"',goodState='"+model.getGoodState()+"',re='"+model.getRe()+"'" +" where clientCode='"+model.getClientCode()+"'";
Connection con = null;
Statement stmt = null;
try{
DataSource dataSource = null;
con = dataSource.getConnection();
stmt =con.createStatement();
stmt.executeUpdate(sql);
con.commit();
}catch(Exception e){
System.out.println("添加客户商品!");
}
finally{
stmt.close();
con.close();
}
} /* public void delete(String clientCode) throws Exception{
String sql = "delete from tClientCode where clientCode='" + clientCode +"'";
Connection con = null;
PreparedStatement stmt = null;
try
{
con = (Connection) DbPool.getConnection();
stmt = ((java.sql.Connection) con).prepareStatement(sql);
stmt.executeUpdate();
((java.sql.Connection) con).commit();
}
catch(Exception e)
{
throw e;
}
finally
{
DbPool.closeStatement(stmt);
DbPool.closeConnection((java.sql.Connection) con);
}
}*/ public ClientGoodsModel queryClientGoodsByClientCode(String clientCode)
throws Exception{
ClientGoodsModel model = null;
String sql = "select clientCode,goodCode,price,startDate,endDate,goodState,re from tClientGoods";
sql += " where clientCode = '"+clientCode+"'";
ResultSet rs = null;
Connection con = null;
Statement statement = null;
try{
DataSource dataSource = null;
con = dataSource.getConnection();
statement =con.createStatement();
rs = statement.executeQuery(sql);
while(rs.next()){
model = new ClientGoodsModel();
model.setClientCode(rs.getString("clientCode").trim());
model.setGoodCode(rs.getString("goodCode").trim());
model.setPrice(rs.getString("price").trim());
model.setStartDate(rs.getString("startDate"));
model.setEndDate(rs.getString("endDate"));
model.setGoodState(rs.getString("goodState").trim());
model.setRe(rs.getString("re").trim());
}
}catch(Exception e){
throw e;
}
finally{
rs.close();
statement.close();
con.close();
}
return model;
}
}
----------------------------------------------------------------------------------------
ClientGoodsProxy
------------------
package com.clientgoods.JavaBeans;import com.clientgoods.JavaBeans.ClientGoodsModel;
import com.clientgoods.dao.ClientGoodsDAO;public class ClientGoodsProxy {
ClientGoodsDAO dao = null;
public ClientGoodsProxy(){
dao = new ClientGoodsDAO();
}
public ClientGoodsModel queryClientGoodsByClientCode(String clientCode) throws Exception{
return dao.queryClientGoodsByClientCode(clientCode);
} /*public ArrayList queryClientGoods(ClientGoodsModel model,Pager pager) throws Exception{
ArrayList lList = new ArrayList();
lList = dao.query(model);
return Utility.generatePager(lList,pager);
} public ArrayList queryClientGoods(ClientGoodsModel model) throws Exception{
return dao.query(model);
} public ClientGoodsModel queryClientGoods(String clientCode) throws Exception{
return dao.queryClientGoods(clientCode);
}*/ public void insertClientGoods(ClientGoodsModel model) throws Exception{
dao.insert(model);
} public void updateClientGoods(ClientGoodsModel model) throws Exception{
dao.update(model);
} /* public void deleteClientGoods(String clientCode) throws Exception{
dao.delete(clientCode);
}*/
}
解决方案 »
- 一个最简单的基础问题,我怎么就绕不出来了呢
- 如何在JAVA中随机产生10位不可重复字串的方法!
- 未来几年开发语言的发展趋势
- 大家觉得孙鑫写的那本web开发怎么样???
- 结合spring,hibernate的缓存?
- WEB SERVICES 发布时的错误,高手求救呀
- 初级问题,大家帮帮忙啊!
- FilePermission的问题
- When do update action on EJB, occurd error, error message is:
- MyBatis+Spring整合,事务配置出现will not be managed by Spring
- 刚学java问一个求格式化String操作 的一个方法
- 我安装JBUILDER2006,我启动TOMCAT后,http://localhost:8080/admin/为何打不开?请指教
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic" %>
<%@ taglib uri="http://struts.apache.org/tags-tiles" prefix="tiles" %>
<html:html>
<HEAD>
<TITLE>
</TITLE>
<SCRIPT>
var winOpenedArr=new Arry();
function add(){
document.forms[0].strutsAction.value="4";
document.forms[0].submit();
}
</SCRIPT>
<META content="text/html; charset=gb2312" http-equiv=Content-Type><LINK
href="<%=request.getContextPath()%>/css/pub.css" rel=stylesheet type=TEXT/CSS>
<META content="MSHTML 5.00.3819.300" name=GENERATOR>
</HEAD><BODY bgColor=#ffffff leftMargin=0 topMargin=0 MARGINHEIGHT="0" MARGINWIDTH="0">
<table>
<td vAlign=top></td><html:form action="/clientgoods/add" method="post" >
<html:hidden property="strutsAction"/>
<html:hidden property="selectedRole"/>
<TD vAlign="top" align="left" width=100%>
<TABLE border=0 cellPadding=0 cellSpacing=0 width=90% align="center">
<TR>
<TD><B><FONT color=#0033cc>客户商品</FONT></B>
</TD>
</TR>
<TR bgColor=#000000>
<TD colSpan=2><IMG alt="" border=0 height=1
src="/images/dot(1).gif" width=1>
</TD>
</TR>
</TABLE>
<BR>
<BR>
<TABLE WIDTH="90%" BORDER="1" CELLSPACING="0" CELLPADDING="3" ALIGN="center" BORDERCOLORDARK="#FFFFFF" BORDERCOLORLIGHT="#666666">
<TR>
<TD WIDTH="21%" ALIGN="RIGHT" BGCOLOR="#e1e1e1">*客户编号:</TD>
<TD WIDTH="79%" BGCOLOR="#FFFFFF">
<html:text property="clientCode" styleClass="Standard-InputCN" size="13" maxlength="20"/>
</TD>
</TR>
<TR>
<TD WIDTH="21%" ALIGN="RIGHT" BGCOLOR="#e1e1e1">*商品编号:</TD>
<TD WIDTH="79%" BGCOLOR="#FFFFFF">
<html:text property="goodCode" styleClass="Standard-InputCN" size="13" maxlength="20"/>
</TD>
</TR>
<TR>
<TD WIDTH="21%" ALIGN="RIGHT" BGCOLOR="#e1e1e1">*售 价:</TD>
<TD WIDTH="79%" BGCOLOR="#FFFFFF">
<html:password property="price" styleClass="Standard-InputCN" size="13" maxlength="20"/>
</TD>
</TR>
<TR>
<TD WIDTH="21%" ALIGN="RIGHT" BGCOLOR="#e1e1e1">*开始日期:</TD>
<TD WIDTH="79%" BGCOLOR="#FFFFFF">
<html:text property="startDate" styleClass="Standard-InputCN" size="13" maxlength="20"/></TD>
</TR>
<TR>
<TD WIDTH="21%" ALIGN="RIGHT" BGCOLOR="#e1e1e1">结束日期:</TD>
<TD WIDTH="79%" BGCOLOR="#FFFFFF">
<html:text property="endDate" styleClass="Standard-InputCN" size="13" maxlength="20"/></TD>
</TD>
<TR>
<TD WIDTH="21%" ALIGN="RIGHT" BGCOLOR="#e1e1e1">商品状态:</TD>
<TD WIDTH="79%" BGCOLOR="#FFFFFF">
<html:select property="goodState" styleClass="Standard-InputCN" >
<!-- <html:options collection="UserTypeList" property="value" labelProperty="label"/>-->
<html:option value="1">正常</html:option>
<html:option value="2">停用</html:option>
</html:select>
</TD>
</TR>
<TR>
<TD WIDTH="21%" ALIGN="RIGHT" BGCOLOR="#e1e1e1">备 注:</TD>
<TD WIDTH="79%" BGCOLOR="#FFFFFF">
<html:textarea property="re" styleClass="Standard-InputCN" />
</TD>
</TR>
<TR ALIGN="CENTER" BGCOLOR="#f2f2f2">
<TD COLSPAN="2">
<input type="submit" name="submit" value="保 存" onClick="return add();"/>
<!--a href="return add();"> <FONT color="#FFFFFF">保 存</FONT></a> -->
<input type="reset" name="reset" value="取 消"/>
</TD>
</TR>
</TABLE>
</td>
</html:form>
</table>
</body>
</html:html>
-----------------------------------------------------------------------------------------
报错:
type Exception reportmessage description The server encountered an internal error () that prevented it from fulfilling this request.exception javax.servlet.ServletException: No getter method for property selectedRole of bean org.apache.struts.taglib.html.BEAN
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:825)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:758)
org.apache.jsp.pages.client.clientgoodsAdd_jsp._jspService(clientgoodsAdd_jsp.java:136)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
com.filters.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:122)
root cause javax.servlet.jsp.JspException: No getter method for property selectedRole of bean org.apache.struts.taglib.html.BEAN
org.apache.struts.taglib.TagUtils.lookup(TagUtils.java:973)
org.apache.struts.taglib.html.BaseFieldTag.prepareValue(BaseFieldTag.java:121)
org.apache.struts.taglib.html.BaseFieldTag.renderInputElement(BaseFieldTag.java:102)
org.apache.struts.taglib.html.BaseFieldTag.doStartTag(BaseFieldTag.java:81)
org.apache.struts.taglib.html.HiddenTag.doStartTag(HiddenTag.java:75)
org.apache.jsp.pages.client.clientgoodsAdd_jsp._jspx_meth_html_hidden_1(clientgoodsAdd_jsp.java:286)
org.apache.jsp.pages.client.clientgoodsAdd_jsp._jspx_meth_html_form_0(clientgoodsAdd_jsp.java:162)
org.apache.jsp.pages.client.clientgoodsAdd_jsp._jspService(clientgoodsAdd_jsp.java:116)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
com.filters.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:122)
note The full stack trace of the root cause is available in the Apache Tomcat/5.0.28 logs.
-------------
selectedRole没有get方法啊!