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 8479345
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T18:59:46+00:00 2026-06-10T18:59:46+00:00

I read the struts manual on wildcard mappings and decided to test some of

  • 0

I read the struts manual on wildcard mappings and decided to test some of the examples for myself. I have an action that points to:

<action name="**" method="getPerson" class="PersonActionBean">
      <result>/person/view.jsp</result>
</action>

This allows me to go anywhere past /person and see the view.jsp as far as I can understand it. So what I’m trying to do now is go to /person/jack/black then I want the getPerson method inside PersonActionBean class to get the URL fields jack and black and do a search in my DB by name and surname then populate an object that will be used on view.jsp

My concern isn’t around the search functionality but around retrieving the fields in the URL from the method getPerson. How would I retrieve jack and black from the URL and use it in my getPerson method?

I’m using struts 2.1.8.1

  • 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-06-10T18:59:47+00:00Added an answer on June 10, 2026 at 6:59 pm

    Method 1 – With struts2-convention plugin

    struts.xml

    <constant name="struts.patternMatcher" value="namedVariable"/>
    

    PersonAction.java

        import org.apache.struts2.convention.annotation.Namespace;
        ...
        @Namespace{"/persons/{param1}/{param2}");
        public class PersonActionBean exends ActionSupport {
            private String param1;
            private String param2;
            // getter and setter
        }
    

    If you call persons/jack/black, the params should be set to param1 = jack, param2 = black

    Method 2 – Without struts2-convention plugin

    PersonAction.java

    public class PersonActionBean exends ActionSupport {
        private String param1;
        private String param2;
        // getter and setter
    }
    

    person.xml

    <package name="person" namespace="/person" extends="website">
        <action name="*/*" method="getPerson" class="PersonActionBean">
                <param name="param1">{1}</param>
                <param name="param2">{2}</param>
                <result>/person/view.jsp</result>
        </action>   
    </package>
    

    struts.xml

    <package name="website" namespace="/" extends="struts-default, json-default">
         ...
        <constant name="struts.enable.SlashesInActionNames" value="true"/>
        <constant name="struts.mapper.alwaysSelectFullNamespace" value="false"/>
         ...
    </package>
    

    References

    Check out Advanced Wildcard

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

Sidebar

Related Questions

i have a struts action that's have a doc as response this is the
I have some read-only data that I want to initialise and then re-initialise periodically
Hi I have something like this in struts.xml <action name=LoginAction class=controller.LoginAction> <result name=error>/Error.jsp</result> <result
I'm trying to download a PDF file in Struts Action class. Problem is that
I have just started learning struts. Most of the tutorials I read, it mentions
I have some repetitive code that is used by a few of my actions
I have an Action, called ShowData that recovers data from the database and put
This is the problem: 45°38'14.07 How can escape it (Struts action read an XLS
I have read that if you declare two structs like this: struct Node {
I have some structs that I want to use for different purposes in my

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.