This article is a mirror article of machine translation, please click here to jump to the original article.

View: 13074|Reply: 2

[JavaEE] struts2 to get the commonly used objects in the servlet

[Copy link]
Posted on 12/24/2014 2:33:07 AM | | |
[mw_shl_code=java,true]        public String fun1() {
                ActionContext actionContext = ActionContext.getContext();
                actionContext.getApplication().put("app", "app scope");
                actionContext.getSession().put("sec", "Secssion Scope");
                actionContext.put("req", "request scope");
                actionContext.put("names", Arrays.asList("Zhang San", "Li Si", "Wang Wu"));
                return "message";

        }
        
        public String getServlet() {
                HttpServletRequest request =  ServletActionContext.getRequest();
                request.setAttribute("req", "request scope");
                request.getSession().setAttribute("sec", "Secssion Scope");
                ServletContext servletContext = ServletActionContext.getServletContext();
                servletContext.setAttribute("app", "app scope");
                return "message";
[/mw_shl_code]




Previous:ajax goes to the database to verify that the username is registered without submitting the form
Next:【Easy language】Mobile phone remote monitoring management source code and modification tutorial
Posted on 12/24/2014 7:57:46 AM |
One "}" parentheses are missing
 Landlord| Posted on 12/24/2014 8:15:28 AM |
See
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com