LinkAction.java
上传用户:yunfeng252
上传日期:2022-07-23
资源大小:12403k
文件大小:3k
- package org.yufeng.struts.action;
- import java.util.List;
- import javax.servlet.http.HttpServletRequest;
- import javax.servlet.http.HttpServletResponse;
- import javax.servlet.http.HttpSession;
- import org.apache.struts.action.ActionForm;
- import org.apache.struts.action.ActionForward;
- import org.apache.struts.action.ActionMapping;
- import org.yufeng.domains.Link;
- import org.yufeng.utils.*;
- public class LinkAction extends BaseAction {
- public ActionForward link_show(ActionMapping mapping, ActionForm form,
- HttpServletRequest request, HttpServletResponse response) {
- HttpSession session = request.getSession();
- try {
- List link_list = this.getlinkService().browseLink();
- session.setAttribute("link_list", link_list);
- } catch (Exception e) {
- e.printStackTrace();
- }
- return mapping.findForward("link_show");
- }
- public ActionForward link_add(ActionMapping mapping, ActionForm form,
- HttpServletRequest request, HttpServletResponse response) {
- try {
- Link link = new Link();
- link.setLi_name(request.getParameter("li_name"));
- link.setLi_url(request.getParameter("li_url"));
- link.setLi_createTime(Tools.getData());
- this.getlinkService().addLink(link);
- } catch (Exception e) {
- e.printStackTrace();
- }
- return new ActionForward("/link.do?method=link_show");
- }
-
- public ActionForward toUpdate_link(ActionMapping mapping, ActionForm form,
- HttpServletRequest request, HttpServletResponse response) {
- HttpSession session = request.getSession();
- try {
- String li_id = request.getParameter("li_id");
- Link link = this.getlinkService().loadLink(Integer.parseInt(li_id));
- session.setAttribute("link", link);
- } catch (Exception e) {
- e.printStackTrace();
- }
- return new ActionForward("/link.do?method=link_show");
- }
-
- public ActionForward link_update(ActionMapping mapping, ActionForm form,
- HttpServletRequest request, HttpServletResponse response) {
- HttpSession session = request.getSession();
- try {
- Link link = new Link();
- link.setLi_id(Integer.parseInt(request.getParameter("li_id")));
- link.setLi_name(request.getParameter("li_editname"));
- link.setLi_url(request.getParameter("li_editurl"));
- link.setLi_createTime(Tools.getData());
- this.getlinkService().updateLink(link);
- session.setAttribute("link", link);
- } catch (Exception e) {
- e.printStackTrace();
- }
- return new ActionForward("/link.do?method=link_show");
- }
-
- public ActionForward link_delete(ActionMapping mapping, ActionForm form,
- HttpServletRequest request, HttpServletResponse response) {
- HttpSession session = request.getSession();
- try {
- String[] link_id = request.getParameterValues("check_id");
- for(int i=0;i<link_id.length;i++){
- this.getlinkService().delLink(Integer.parseInt(link_id[i]));
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- return new ActionForward("/link.do?method=link_show");
- }
- }