该类可获取一些请求地址,在自定义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.jsp 10 System.out.println("PageComponent.start()"+stringBuffer.toString()); 11 12 //获取的是请求后台的地址,其中的参数的值 13 Object object=req.getAttribute("pageNo"); 14 System.out.println("PageComponent.start()"); 15 //key--->value 16 //javax.servlet.forward.query_string-->(获取请求参数字符串)pageNo=1&seachName=%E5%B0%9A%E6%99%93%E9%A3%9E 17 //javax.servlet.forward.request_uri-->(获取请求路径到方法名)/Struts2HibernateSpring/StudentAction!queryStudent 18 //javax.servlet.forward.context_path-->( 获取项目名)/Struts2HibernateSpring 19 //javax.servlet.forward.servlet_path--> (获取请求的action名字+method名字)/Struts2HibernateSpring 20 //struts.request_uri --->(获取请求路径到方法名)/Struts2HibernateSpring/StudentAction!queryStudent 21 //struts.view_uri -->(获取struts请求返回的jsp的路径)/list.jsp 22 //__cleanup_recursion_counter---> 1 23 //characterEncodingFilter.FILTERED--> true 24 //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@10f892d 26 //struts.valueStack--->com.opensymphony.xwork2.ognl.OgnlValueStack@1dc2914 27 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
时间: 2024-09-29 15:09:54