短学期实训——第二篇
在這三天中我們的實訓也逐步進入正軌,我們做了查詢,刪除,條件查詢,預覽修改,預覽
一.在查詢中
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 FindCustByCdAction extends ActionSupport{
private CustService cdtCustService;
Cust cust;
public CustService getCdtCustService() {
return cdtCustService;
}
public void setCdtCustService(CustService cdtCustService) {
this.cdtCustService = cdtCustService;
}
public Cust getCust() {
return cust;
}
public void setCust(Cust cust) {
this.cust = cust;
}
@Override
public String execute() throws Exception {
// TODO Auto-generated method stub
Map map = (Map)ActionContext.getContext().get("request");
map.put("list", this.cdtCustService.findCustByCondition(cust));
return SUCCESS;
}
}
?
我們會出現跳轉錯誤和屬性錯誤,我們仔細查找發現原來是代碼的名稱不同而已
然后鏈接到網頁出現的頁面
2.緊接著就是刪除操作了
package com.crm.action;
import com.crm.bean.Cust;
import com.crm.service.CustService;
import com.opensymphony.xwork2.ActionSupport;
@SuppressWarnings("serial")
public class RemoveCustAction extends ActionSupport{
private Cust cust;
private CustService rmvCstService;
public CustService getRmvCstService() {
return rmvCstService;
}
public void setRmvCstService(CustService rmvCstService) {
this.rmvCstService = rmvCstService;
}
@SuppressWarnings("unchecked")
@Override
public String execute() throws Exception {
this.rmvCstService.removeCust(cust);
return SUCCESS;
}
public Cust getCust() {
return cust;
}
public void setCust(Cust cust) {
this.cust = cust;
}
}在刪除操作中我出現的問題不是很難,只要細心一點,問題都解決了
條件查詢也就是在這個的基礎上進行
3.修改,修改分為預覽修改和修改
對于預覽修改就是修改的前調步驟
package com.crm.action;
import com.crm.bean.Cust;
import com.crm.service.CustService;
import com.opensymphony.xwork2.ActionSupport;
public class UpdataCustAction extends ActionSupport{
/**
*
*/
private static final long serialVersionUID = 1L;
private Cust cust;
private CustService upCustService;
public Cust getCust() {
return cust;
}
public void setCust(Cust cust) {
this.cust = cust;
}
public CustService getUpCustService() {
return upCustService;
}
public void setUpCustService(CustService upCustService) {
this.upCustService = upCustService;
}
@Override
public String execute() throws Exception {
// TODO Auto-generated method stub
this.upCustService.findCustById(cust.getId());
return SUCCESS;
}
?在修改中我們出現的錯誤是
?
經過這三天我也發現了在連接數據表的時候,首先要進行數據表的連接
在JSP中的action請求中,首先要進行action的實現,利用struts.xml連接前端,利用action.xml連接后端。
Action前端
struts.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<package name="customer" extends="struts-default">
<!-- 保存 -->
<action name="saveCustomer" class="saveCustomerAction">
<result name="success" type="redirect">/jsp/custInfo.jsp</result>
<result name="input">/custSave.jsp</result>
</action>
<!-- 查詢 -->
<action name="listCust" class="listCustAction">
<result>/jsp/custInfo.jsp</result>
</action>
<!-- 刪除 -->
<action name="removeCust" class="removeCustAction">
<result>/jsp/custInfo.jsp</result>
</action>
<!-- 條件查詢 -->
<action name="findCdtCustList" class="findCdtAction">
<result>/jsp/custInfo.jsp</result>
</action>
<!-- 修改預覽 -->
<action name="updatePreviewCust" class="updatePreviewCustAction">
<result name="success">/jsp/custUpdate.jsp</result>
</action>
<!-- 修改 -->
<action name="updateCust" class="updateCustAction">
<result name="success" type="redirect">listCust.action</result>
<result name="input">/jsp/custUpdate.jsp</result>
</action>
</package>
</struts>
Jsp請求
這三天不停地查找bug,每次查找的bug都使我不斷地去反思,去思考,使我把之前學習的java內容復習了一遍,溫故而知新,很充實,很快樂。
轉載于:https://www.cnblogs.com/ctt-2017/p/7106218.html
總結
以上是生活随笔為你收集整理的短学期实训——第二篇的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: GCC安装UBUNTU
- 下一篇: SQL SERVER 通用分页存储过程