前三天只要是搭建平台,构建链接,而这三天的实践内容则主要是实现数据的新增,删除,查询和修改。
com.crm.action.CustSaveAction.java新增信息代码:
package com.crm.action; import com.crm.bean.Cust; import com.crm.service.CustService; import com.opensymphony.xwork2.ActionSupport; public class CustSaveAction extends ActionSupport{ private CustService service; private Cust cust; public Cust getCust() { return cust; } public void setCust(Cust cust) { this.cust = cust; } public CustService getService() { return service; } public void setService(CustService service) { this.service = service; } @Override public String execute() throws Exception { // TODO Auto-generated method stub this.service.saveCustomer(cust); return SUCCESS; } }
com.crm.action.FindCustByCdtAction.java查询信息代码:
package com.crm.action; import java.util.Map; import com.crm.bean.Cust; import com.crm.service.CustService; import com.opensymphony.xwork2.ActionContext; import com.opensymphony.xwork2.ActionSupport; public class FindCustByCdtAction extends ActionSupport{ private Cust cust; private CustService findCdtService; public Cust getCust() { return cust; } public void setCust(Cust cust) { this.cust = cust; } public CustService getFindCdtService() { return findCdtService; } public void setFindCdtService(CustService findCdtService) { this.findCdtService = findCdtService; } @SuppressWarnings({ "unchecked", "unchecked" }) @Override public String execute() throws Exception { // TODO Auto-generated method stub Map map=(Map)ActionContext.getContext().get("request"); map.put("list", this.findCdtService.findCustByCondition(cust)); return SUCCESS; } }
com.crm.action.RemoveCustAction.java删除信息代码:
package com.crm.action; import com.crm.bean.Cust; import com.crm.service.CustService; import com.opensymphony.xwork2.ActionSupport; public class RemoveCustAction extends ActionSupport{ private Cust cust; private CustService service; public Cust getCust() { return cust; } public void setCust(Cust cust) { this.cust = cust; } public CustService getService() { return service; } public void setService(CustService service) { this.service = service; } @Override public String execute() throws Exception { // TODO Auto-generated method stub this.service.removeCustomer(cust); return SUCCESS; } }
com.crm.action.UpdatePreviewCustAction.java更改信息数据代码:
package com.crm.action; import com.crm.bean.Cust; import com.crm.service.CustService; import com.opensymphony.xwork2.ActionSupport; public class UpdatePreviewCustAction extends ActionSupport { private CustService updatePreviewCustService; private Cust customer; public Cust getCustomer() { return customer; } public void setCustomer(Cust customer) { this.customer = customer; } public CustService getUpdatePreviewCustService() { return updatePreviewCustService; } public void setUpdatePreviewCustService(CustService updatePreviewCustService) { this.updatePreviewCustService = updatePreviewCustService; } @Override public String execute() throws Exception { // TODO Auto-generated method stub customer = this.updatePreviewCustService.findCustomerById(customer .getId()); return SUCCESS; } }
com.crm.action.TypeAction.java下拉菜单选择性别代码
package com.crm.action; import java.util.ArrayList; import java.util.List; import com.crm.bean.Type; import com.opensymphony.xwork2.ActionSupport; public class TypeAction extends ActionSupport { private List<Type> strList = new ArrayList<Type>(); public List<Type> getStrList() { List<Type> list = new ArrayList<Type>(); Type type1 = new Type(); type1.setId("1"); type1.setName("男"); Type type2 = new Type(); type2.setId("2"); type2.setName("女"); Type type3 = new Type(); type3.setId("3"); type3.setName("其他"); list.add(type1); list.add(type2); list.add(type3); this.strList = list; return strList; } public void setStrList(List<Type> strList) { this.strList = strList; } @Override public String execute() throws Exception { // TODO Auto-generated method stub return SUCCESS; } }
custAdd.jsp新增客户信息界面代码
<body> <CENTER> <div><font size="5" color="red">新增客户信息</font></div> <center></center> <div style="width:20px"></div> <div class="divcss5"> <s:form action="saveCust" theme="simple"> <div style="width:10px"></div> 客户编号:<s:textfield name="cust.custno" label="custno"></s:textfield> 性别:<s:select name="strList" headerKey="0" headerValue="-----------请选择-----------" list="#list.strList" listKey="id" listValue="name"/><br> 客户名称:<s:textfield name="cust.custname" label="custname"></s:textfield> 年龄:<s:textfield name="cust.telephone" label="telephone"></s:textfield><br> <tr><td> </td></tr> <s:submit value="保存" onClick="window.close();"></s:submit> <input width="100" type = "button" id = "smt" name = "btn" value="关闭" onClick="window.close();"/> </s:form> </div> <div style="width:20px"></div> </CENTER> </body>
custSave.jsp新增客户信息界面代码
<body> <CENTER> <div><font size="5" color="red">新增客户信息</font></div> <center></center> <div style="width:20px"></div> <div class="divcss5"> <s:form action="saveCust" theme="simple"> <div style="width:10px;padding:10px"></div> 客户编号:<s:textfield name="cust.custnumber" label="客户编号"></s:textfield><br> 客户名称:<s:textfield name="cust.custname" label="客户名称"></s:textfield><br> 客户性别:<s:textfield name="cust.custsex" label="客户性别"></s:textfield><br> 电话号码:<s:textfield name="cust.custphone" label="电话号码"></s:textfield><br> <tr><td> </td></tr> <s:submit value="保存" style="margin:10px"></s:submit> <input style="margin:10px" width="100" type = "button" id = "smt" name = "btn" value="关闭" onClick="window.close();"/> </s:form> </div> <div style="width:20px"></div> </CENTER> </body>
custInfo.jsp客户信息维护界面代码
<body> <CENTER> <center><div><font color="red" size="6">客户信息维护</font></div></center> <div style="width:20px"></div> <div class="divcss5"> <s:form action="findCdtCustList" theme="simple"> <div style="width:10px"></div> 客户编号:<s:textfield name="cust.custno" label="custno"></s:textfield> 客户名称:<s:textfield name="cust.custname" label="custname"></s:textfield><br> 出生日期:<s:textfield name="cust.address" label="address"></s:textfield> 电话号码:<s:textfield name="cust.telephone" label="telephone"></s:textfield><br> <div style="width:20px"></div> <input width="100" type = "button" id = "add" name = "btn" value="新增" onClick="openwind();"/> <s:submit value="查询"></s:submit> <input width="100" type = "button" id = "smt" name = "btn" value="返回" onClick="history.go(-1)"/> </s:form> </div> <div style="width:20px"></div> <table border="1" width="47%" class="table"> <tr> <td>客户编号</td> <td>姓名</td> <td>性别</td> <td>年龄</td> <td>联系方式</td> <td>职务</td> <td>出生日期</td> <td width="80">操作</td> </tr> <s:iterator value="#request.list" id="customer"> <tr> <td><s:property value="#customer.custno"/></td> <td><s:property value="#customer.custname"/></td> <td> <s:if test="#customer.sex == 1"> <s:property value="‘男‘"/> </s:if> <s:elseif test="#customer.sex == 2"> <s:property value="‘女‘"/> </s:elseif> <s:elseif test="#customer.sex == 3"> <s:property value="‘其他‘"/> </s:elseif> </td> <td><s:property value="#customer.age"/></td> <td><s:property value="#customer.telephone"/></td> <td><s:property value="#customer.position"/></td> <td><s:property value="#customer.logindate"/></td> <td> <s:a href="updatePreviewCust.action?customer.id=%{#customer.id}">修改</s:a> <s:a href="delectCustomer.action?customer.id=%{#customer.id}" onClick="return funDelete();">删除</s:a> </td> </tr> </s:iterator> </table> </CENTER> </body>
custUpdate.jsp修改客户信息界面代码
<body> <CENTER> <div><font size="5" color="red">修改客户信息</font></div> <center></center> <div style="width:20px"></div> <div class="divcss5"> <s:form action="updateCust" theme="simple"> <div style="width:10px"></div> 客户编号:<s:textfield name="customer.custno" value="%{customer.custno}" label="custno"></s:textfield> 性别:<s:select name="strList" headerKey="0" value="%{customer.sex}" headerValue="-----------请选择-----------" list="#list.strList" listKey="id" listValue="name"/><br> 客户名称:<s:textfield name="customer.custname" value="%{customer.custname}" label="custname"></s:textfield> 年龄:<s:textfield name="customer.telephone" label="%{customer.telephone}"></s:textfield><br> <s:hidden name="customer.id" value="%{customer.id}" ></s:hidden> <tr><td> </td></tr> <s:submit value="保存" onClick="window.history.back(-1);"></s:submit> <input width="100" type = "button" id = "smt" name = "btn" value="关闭" onClick="history.go(-1);"/> </s:form> </div> <div style="width:20px"></div> </CENTER> </body>
待问题:个人电脑包冲突报错,应该是操作系统和jdk的问题;更改信息的网页还会报错505
时间: 2024-10-02 18:52:16