STRUTS2 annotations using interceptors interceptor and Interceptor-stack

Source: Internet
Author: User

<!-- pc User Center operation, must be logged in  --><package name= "User_login"  namespace= "/"   extends = "Json-default,struts-default" ><interceptors>   <interceptor name= "ress"   class= "Com.common.interceptor.ErrorInterceptor"  />   <interceptor name= " Userislogin " class=" Com.common.interceptor.Check_P_UserIsLogin " />    < Interceptor-stack name= "Defaultstacks" ><interceptor-ref name= "ress" ></interceptor-ref ><interceptor-ref name= "Userislogin" ></interceptor-ref><interceptor-ref name= " Defaultstack "></interceptor-ref>    </interceptor-stack>      </interceptors>   <global-results><result name= "PloginUI" >/ Web-inf/jsp/pc/login.jsp</result><result name= "Error" >/WEB-INF/jsp/pc/404.jsp</result> <result name= "Input" &GT;/web-inf/jsp/pc/404.jsp</result></global-results> </package> 


Interceptor above

Note that the action configuration, @ParentPackage need to be set to the Interceptor's package name or inheritance, or an error


The error message is:

"Unable to find interceptor class referenced by Ref-name XYZ" because the Interceptor Convention scan the action class, there is no interceptor specified interceptor. Handled by: 1 use @parentpackage annotations (or specify struts.convention.default.parent.package) to specify the package that defines the interceptor; 2 Create a package and inherit the package that defines the interceptor, using @parentpackage (or struts.convention.default.parent.package) Specify the package to run the solution under:
@Controller @scope ("prototype") @Namespace ("") @ParentPackage ("User_login") @Results (value={@Result (name =   "Ann_json", type =  "json", params={"root", "Jsonmap"}), @Result (name =  "Ann_user", location =  "/web-inf/jsp/pc/user/user.jsp"), @Result (name =  "Ann_userinfo", location =   "/web-inf/jsp/pc/user/info.jsp"), @Result (name =  "Ann_registererror",location =  "/ Web-inf/jsp/pc/register.jsp "), @Result (name = " Ann_login " ,location="/web-inf/jsp/pc/login.jsp ") }) public class puseraction extends baseaction<user> {private static  final long serialversionuid = 2324932911275746283l;//Query user basic information @action (value =  " Ann_info ", interceptorrefs={@InterceptorRef (" Defaultstacks ")}) Public string ann_info () {user  users =  (user)  actioncontext.getcontext (). GetSession (). Get ("user"); System.out.println ((null!=users) + "existence session"); if (null!=users) {login_user = users;} return  "Ann_userinfo";}}


This article is from the "Green Years" blog, be sure to keep this source http://alex233.blog.51cto.com/8904951/1763867

STRUTS2 annotations using interceptors interceptor and Interceptor-stack

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.