package com.haha.action; import java.io.UnsupportedEncodingException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; public abstract class AbsMyStrutsAction { //³õʼ»¯ public void init(HttpServletRequest req,HttpServletResponse resp){ this.req=req; this.resp=resp; this.session=req.getSession(); try { this.req.setCharacterEncoding("UTF-8"); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } } protected HttpServletRequest req; protected HttpServletResponse resp; protected HttpSession session; public abstract void run(); protected void forward(String url){ try { req.getRequestDispatcher(url).forward(req, resp); } catch (Exception e) { e.printStackTrace(); } } protected void toUrl(String url){ try { resp.sendRedirect(url); } catch (Exception e) { e.printStackTrace(); } } }