Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6792701
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T18:00:13+00:00 2026-05-26T18:00:13+00:00

we are using Struts2 in our code and I have scenario where I need

  • 0

we are using Struts2 in our code and I have scenario where I need to add custom parameter to the interceptor.
I have defined setter and getter in the interceptor

public Collection<Class<?>> getGroups();
public void setGroups(String groupsString);

I have interceptor defined in the stack:

<interceptor-ref name="beanValidatorInterceptor">
    <param name="excludeMethods">*</param>
</interceptor-ref>

And I am setting additional parametres on action level

<action name="...">
  <interceptor-ref name="loginRequired">
    <param name="beanValidatorInterceptor.includeMethods">execute</param>
    <param name="beanValidatorInterceptor.groups">com.company.MyGroup</param>
  </interceptor-ref>
  <result>some.jsp</result>
</action>

I have one issue and one question

  • Issue: groups parameters is not set (setGroups() is not called). Interceptor is called and the includeMethods are set.
  • Question: do you happen to know what is interceptor lifecycle. Is it safe to set includeMethods and groups on the action level. In other words actions are sharing same stack but need to pass different parameters
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T18:00:14+00:00Added an answer on May 26, 2026 at 6:00 pm

    Yes and no. Interceptors are like servlets–there is only one instance of an interceptor.*

    Note, however, that with your current definition, only the “loginRequired” interceptor is defined on that action–none of the other framework interceptors will be run. If you declare an <interceptor-ref> on an action, you must define all the interceptors.

    From the config it looks as though you’re trying to define what group may access an action: that information should be stored in the action, not the interceptor, since it is the action that’s being instrumented.

    You have several options. You may use the “staticParams” interceptor to set the information on the action, you may define and implement an interface on the action and include a method that retrieves the permissions for that action, or use annotations on the action and interrogate the action and/or action method within the interceptor.

    IMO the interceptor should be generic and not receive these types of parameters: you are adding action metadata to an interceptor. Instead, add the action metadata to the action, and use the interceptor to act on that metadata.

    *Per interceptor-ref, actually; there can be multiple instances of an interceptor, but only when explicitly referenced in a stack declaration, and even then, there will be only one instance of the interceptor shared among requests that flow through that stack.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code to do a doubleselect using Struts2 and the jquery
I have a Struts2 webapp, in which I compiled using the Tomcat 5.5 libraries.
I'm working on on a site built using struts2. The vast majority of our
I am using struts2 for developing a web application. I have include the required
I am using struts2 in my project. Have to generate image in my action
I'm Using Struts2 in jsp page i have iterator values for checkbox. how to
I am using struts2, for that my struts.xml file contains code like : <?xml
Using Struts2, I compute a link in my java code and expose the link's
I'm using Struts2, Spring, and Hibernate. I have written a simple Excel file called
I am using struts2 and i have property and want to make it a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.