首页 > 代码库 > Struts2中StrutsRequestWrapper类

Struts2中StrutsRequestWrapper类

该类可获取一些请求地址,在自定义struts2标签时用到

 1 //获取值栈 2         Map cont= this.getStack().getContext();    3         StrutsRequestWrapper req=(StrutsRequestWrapper)cont.get(StrutsStatics.HTTP_REQUEST);   4         //获取请求action的地址 5         String url=(String)req.getAttribute("javax.servlet.forward.request_uri"); 6         System.out.println("PageComponent.start()"+url); 7          8         //获取的标签所在jsp页面的全路径 9         StringBuffer stringBuffer=req.getRequestURL();//http://localhost:8080/Struts2HibernateSpring/list.jsp10         System.out.println("PageComponent.start()"+stringBuffer.toString());11         12         //获取的是请求后台的地址,其中的参数的值13         Object object=req.getAttribute("pageNo");14         System.out.println("PageComponent.start()");15         //key--->value16         //javax.servlet.forward.query_string-->(获取请求参数字符串)pageNo=1&seachName=%E5%B0%9A%E6%99%93%E9%A3%9E17         //javax.servlet.forward.request_uri-->(获取请求路径到方法名)/Struts2HibernateSpring/StudentAction!queryStudent18         //javax.servlet.forward.context_path-->( 获取项目名)/Struts2HibernateSpring19         //javax.servlet.forward.servlet_path--> (获取请求的action名字+method名字)/Struts2HibernateSpring20         //struts.request_uri --->(获取请求路径到方法名)/Struts2HibernateSpring/StudentAction!queryStudent21         //struts.view_uri -->(获取struts请求返回的jsp的路径)/list.jsp22         //__cleanup_recursion_counter---> 123         //characterEncodingFilter.FILTERED--> true24         //struts.actionMapping--->ActionMapping{name=‘StudentAction‘, namespace=‘/‘, method=‘queryStudent‘, extension=‘null‘, params=null, result=null}25         //org.springframework.web.context.request.async.WebAsyncManager.WEB_ASYNC_MANAGER--->org.springframework.web.context.request.async.WebAsyncManager@10f892d26         //struts.valueStack--->com.opensymphony.xwork2.ognl.OgnlValueStack@1dc291427         Enumeration<String> pd=req.getAttributeNames();28         while(pd.hasMoreElements()){29             String nameString=pd.nextElement();30             Object object2=req.getAttribute(nameString);31             System.out.println("PageComponent.start()"+object2);32         }33         
View Code

 

Struts2中StrutsRequestWrapper类