码迷,mamicode.com
首页 > 其他好文 > 详细

structs2.8创建拦截器

时间:2017-06-10 19:30:58      阅读:190      评论:0      收藏:0      [点我收藏+]

标签:void   创建   res   name   .com   ack   ext   cep   end   

控制层

 1 public class PrintUsername {
 2     private String username;
 3 
 4     public String getUsername() {
 5         return username;
 6     }
 7 
 8     public void setUsername(String username) {
 9         this.username = username;
10     }
11 
12     public String execute(){
13         System.out.println("PrintUSrn execute()");
14         return "toPrintUsernameJSP";
15     }
16 }

配置struts.xml

 1 <struts>
 2 <package name="struct2.8" extends="struts-default">
 3 
 4     
 5     
 6     <interceptors>
 7         <interceptor name="myinterceptor" class="myinterceptor.MyInterceptor">
 8         </interceptor>
 9         <interceptor-stack name="myInterceptorStack">
10             <interceptor-ref name="defaultStack"></interceptor-ref>
11             <interceptor-ref name="myinterceptor"></interceptor-ref>
12         </interceptor-stack>
13     </interceptors>
14 
15     <default-interceptor-ref name="myInterceptorStack"></default-interceptor-ref>
16 
17     <action name="printUsername" class="controller.PrintUsername">
18         <result name="toPrintUsernameJSP">
19             /printUsername.jsp
20         </result>
21     </action>
22 </package>
23 
24 </struts>

显示层列出

 

控制台界面

技术分享

 

structs2.8创建拦截器

标签:void   创建   res   name   .com   ack   ext   cep   end   

原文地址:http://www.cnblogs.com/zhangqiuchi/p/6979443.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!