wood burning stoves 2.0*
The moose likes Struts and the fly likes help needing restructure of struts.xml using wildcards Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "help needing restructure of struts.xml using wildcards" Watch "help needing restructure of struts.xml using wildcards" New topic
Author

help needing restructure of struts.xml using wildcards

Kelly Dolan
Ranch Hand

Joined: Jan 08, 2002
Posts: 109
Hi all! First let me say I'm embarrassed that I even need to ask this question as I thought I should have found a solution by now.

We have many Struts actions (2.2.3.1) all in the same package and our struts.xml file uses one <action> w/ a wildcard to handle all of the mappings (see below). We want to re-organize our Struts actions into subpackages and thought we'd have one <action> per subpackage. For the life of me, we cannot get this to work. Below is our current configuration followed by some changes we attempted based on the documentation and posts I ran into. I appreciate all help.

CURRENT CONFIGURATION:

The struts.xml file:


Our JavaScript code used to call the actions looks like the following where 'actionName' is something like 'GetAbc'.


Our web.xml contains


Lastly, the URL to start our application is something like http://server:port/MyApp/viewer. This entire configuration WORKS.


CHANGES ATTEMPTED:

Now we have some Struts actions in /com/mycompany, /com/mycompany/aaa, /com/mycompany/bbb, etc.

#1: The struts.xml file:


Changed actionName values to 'aaa/GetAbc' so Ajax.Request is now '/s/aaa/GetAbc.action'.

RESULT: On post of http://server:port/MyApp/viewer/s/aaa/GetAbc.action, Unable to instantiate Action, com.mycompany.GetAbcAction, defined for 'GetAbc' root cause ClassNotFoundException for com.mycompany.GetAbcAction. Seems like it's still matching on "*" pattern. Don't understand why it's not matching later pattern. Tried defining "aaa/*" pattern before and after "*" w/ same result. Eventually found documentation that said when 1+ patterns match, last wins.

#2 - changed struts.xml to use Advanced Wildcard regex constants (see http://struts.apache.org/2.2.3/docs/wildcard-mappings.html).

RESULT: application no longer deployed so removed

#3 - try defining different package


RESULT - same as #1 above.

Help! Thanks!
Kelly
 
jQuery in Action, 2nd edition
 
subject: help needing restructure of struts.xml using wildcards
 
Similar Threads
How to configure tiles with JSF+Struts2 Integration ?
struts2: howto correctly deligate actions on the struts.xml's include files
struts 2: specifying pages with no name extension?
Issue configuring global results
After upgrading from 2.0.x to 2.2.x, static content no longer loads