?? customerscoreaction.java
字號(hào):
/*
* 作者:武律
* 時(shí)間:2007年11月8日
* 功能:處理個(gè)人消費(fèi)積分
*/
package com.mole.struts.action;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import com.mole.struts.bean.Page;
import com.mole.struts.dao.CustomerScoreDAO;
/**
* MyEclipse Struts Creation date: 11-08-2007
*
* XDoclet definition:
*
* @struts.action path="/customerscore" name="customerscoreForm"
* input="/customerscore.jsp" scope="request" validate="true"
* @struts.action-forward name="getInfoSuccess" path="/customerscore.jsp"
*/
public class CustomerScoreAction extends Action {
/*
* Generated Methods
*/
/**
* Method execute
*
* @param mapping
* @param form
* @param request
* @param response
* @return ActionForward
*/
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
try {
request.setCharacterEncoding("utf-8");
} catch (UnsupportedEncodingException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
String storename = null;
storename = request.getParameter("select");
if (storename == null) {
if ((request.getAttribute("select")) != null)
storename = request.getAttribute("select").toString();
} else {
request.setAttribute("select", storename);
}
if (request.getParameter("kind") != null
&& (request.getParameter("kind").equals("all"))) {
storename = null;
request.removeAttribute("select");
}
CustomerScoreDAO dao = new CustomerScoreDAO();
String LoginID = String.valueOf(request.getSession().getAttribute(
"user"));
if (LoginID == null)
return mapping.findForward("goLogin");
String end = "";
// 生成列表
if (request.getSession().getAttribute("store") == null) {
ArrayList<Object[]> store;
try {
store = dao.getStore(LoginID);
} catch (Exception e) {
e.printStackTrace();
HttpSession session = request.getSession();
session.setAttribute("title", "錯(cuò)誤信息");
session.setAttribute("message", "用戶(hù)名或密碼錯(cuò)誤,請(qǐng)重新登陸!");
session.setAttribute("returnUrl", "show.do?action=goLogin");
return mapping.findForward("goMessage");
}
request.setAttribute("store", store);
}
if (storename != null && !"".equals(storename))
end = "and a.StoreID='" + storename + "'";
if (storename == null)
end = "";
Page page = new Page();
int pageSize = (request.getParameter("pageSizeSelect") == null ? 10
: Integer.parseInt(request.getParameter("pageSizeSelect")));
int currentPage = (request.getParameter("page") == null ? 1 : Integer
.parseInt(request.getParameter("page")));
int count = dao.getCount(LoginID, end);
page.setPageSize(pageSize);
page.setRecordCount(count);
page.setPageCount((count + pageSize - 1) / pageSize);
page.setCurrentPage(currentPage);
ArrayList<Object[]> list;
try {
list = dao.getScore(LoginID, end, page.getCurrentPage(), page
.getPageSize());
} catch (Exception e) {
e.printStackTrace();
HttpSession session = request.getSession();
session.setAttribute("title", "錯(cuò)誤信息");
session.setAttribute("message", "用戶(hù)名或密碼錯(cuò)誤,請(qǐng)重新登陸!");
session.setAttribute("returnUrl", "show.do?action=goLogin");
return mapping.findForward("goMessage");
}
request.setAttribute("Page", page);
if (list == null)
return mapping.findForward("getInfoSuccess");
request.setAttribute("ScoreList", list);
return mapping.findForward("getInfoSuccess");
}
}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -