1 16 17 package examples.app2; 18 19 import java.io.IOException ; 20 import javax.servlet.ServletException ; 21 import javax.servlet.http.HttpServletRequest ; 22 import javax.servlet.http.HttpSession ; 23 import javax.servlet.http.HttpServletResponse ; 24 import org.apache.struts.action.Action; 25 import org.apache.struts.action.ActionError; 26 import org.apache.struts.action.ActionErrors; 27 import org.apache.struts.action.ActionForm; 28 import org.apache.struts.action.ActionForward; 29 import org.apache.struts.action.ActionMapping; 30 import org.apache.struts.action.ActionMessage; 31 import org.apache.struts.action.ActionMessages; 32 33 39 public class DemoAction extends Action 40 { 41 42 53 public ActionForward execute(ActionMapping mapping, 54 ActionForm form, 55 HttpServletRequest request, 56 HttpServletResponse response) 57 throws IOException , ServletException 58 { 59 String action; 60 HttpSession session; 61 62 ActionErrors errors = new ActionErrors(); 64 65 errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("error01")); 67 errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("error02")); 68 69 errors.add("language", new ActionMessage("error10")); 71 errors.add("language", new ActionMessage("error11")); 72 73 saveErrors(request, errors); 75 76 77 ActionMessages messages = new ActionMessages(); 79 80 messages.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("message01")); 82 messages.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("message02")); 83 84 messages.add("foobar", new ActionMessage("message10")); 86 messages.add("foobar", new ActionMessage("message11")); 87 88 saveMessages(request, messages); 90 91 92 saveToken(request); 94 95 return (mapping.findForward("home")); 96 97 } 98 } 99 100 | Popular Tags |