📄 uncommandwordlistaction.java
字号:
package com.longtime.wap.module.cellphone.web.action;
import java.util.ArrayList;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.commons.validator.GenericValidator;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.springframework.web.struts.DispatchActionSupport;
import com.longtime.wap.common.WapConstant;
import com.longtime.wap.common.web.Page;
import com.longtime.wap.common.web.PageConstant;
import com.longtime.wap.module.cellphone.service.UncommandWordService;
/**
* 处理列表页请求
*
* @author shiz
* @date Nov 19, 2007
*/
public class UncommandWordListAction extends DispatchActionSupport {
private static final Log LOGGER =
LogFactory.getLog(UncommandWordListAction.class);
private UncommandWordService uncommandWordService;
/**
* 注入服务对象
*
* @param uncommandWordService
* 服务对象
*/
public void setUncommandWordService(
UncommandWordService uncommandWordService) {
this.uncommandWordService = uncommandWordService;
}
/**
* 处理列表页请求
*
* @param mapping
* ActionMapping对象
* @param form
* ActionForm对象
* @param request
* HttpServletRequest对象
* @param response
* HttpServletResponse对象
* @return ActionForward对象
* @throws Exception
* 异常对象
*/
@SuppressWarnings("unchecked")
public ActionForward listUncommandWord(ActionMapping mapping,
ActionForm form, HttpServletRequest request,
HttpServletResponse response) throws Exception {
try {
Page page = null;
String pageNumber = request.getParameter(PageConstant.PARA_PAGE);
if (GenericValidator.isBlankOrNull(pageNumber)) {
page = new Page(1);
} else {
page = new Page(Integer.parseInt(pageNumber));
}
request.setAttribute("uncommandWords", uncommandWordService
.getUncommandWords(page));
request.setAttribute(PageConstant.ATTR_PAGE, page);
} catch (Exception ex) {
LOGGER.error(ex);
ex.printStackTrace();
}
return mapping.findForward("listUncommandWord");
}
/**
* 处理删除请求
*
* @param mapping
* ActionMapping对象
* @param form
* ActionForm对象
* @param request
* HttpServletRequest对象
* @param response
* HttpServletResponse对象
* @return ActionForward对象
* @throws Exception
* 异常对象
*/
public ActionForward deleteUncommandWords(ActionMapping mapping,
ActionForm form, HttpServletRequest request,
HttpServletResponse response) throws Exception {
List<String> messages = new ArrayList<String>();
try {
String[] uncommandWordIds = request
.getParameterValues("deleteUncommandWordIds");
;
this.uncommandWordService.deleteUncommandWords(uncommandWordIds);
messages.add("信息删除成功!");
} catch (Exception ex) {
LOGGER.error(ex);
ex.printStackTrace();
}
if (request.getAttribute(WapConstant.WAP_GLOBAL_MESSAGES) != null) {
request.removeAttribute(WapConstant.WAP_GLOBAL_MESSAGES);
}
request.setAttribute(WapConstant.WAP_GLOBAL_MESSAGES, messages);
return mapping.findForward("uncommandWords");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -