You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Richard Sayre <ri...@gmail.com> on 2007/07/03 14:29:36 UTC
Struts 2 Package Namespace and URL generation
I have a package defined as follows:
<package name="design" namespace="/Design" extends="struts-default">
<action name="selectCustomer">
<result>/JSP/Design/selectCustomer.jsp</result>
</action>
<action name="selectLocation">
<result>/JSP/Design/location.jsp</result>
</action>
</package>
I am using the name space to encapsulate the JSP from the user.
When I create a form using struts tags like this:
<s:form action="selectLocation"> <s:form>
The 'action' is rendered as follows:
<form id="selectLocation" name="selectLocation" onsubmit="return
true;" action="/WebTest/Design/selectLocation.action" method="post">
Which is correct. However if I specify the name space in the action
attribute like this:
<s:form action="/Design/selectLocation"> <s:form>
The following will render:
<form id="selectLocation" name="selectLocation" onsubmit="return
true;" action="/WebTest/Design/selectLocation" method="post">
With out the .action appended to the URL.
I plan on having a selectLocation action in several different name
spaces. If I render the form the first way:
<s:form action="selectLocation"> <s:form>
How will struts know which name space I am referring to? It seems
that I cannot hard code the name space or the .action will not appear.
I could hard code the .action but I would prefer not to in case this
.action extension ever changes.
Thank you,
Rich
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Adding global-exception-mappings tag to struts.xml causes SAXParseException
Posted by Anton Pussep <an...@pussep.de>.
> The DTD warning is giving you the expected *order* of
> elements.
Aha, good to know. =) Yes, it works perfectly fine. Thanks a lot!
Best,
Anton
Re: Adding global-exception-mappings tag to struts.xml causes SAXParseException
Posted by Dave Newton <ne...@yahoo.com>.
--- Anton Pussep <an...@pussep.de> wrote:
> The content of element type "package" must match
> "([...],global-exception-mappings?,action*)".
> it seems like my struts.xml matches the DTD very
well
Not particularly ;)
> <package name="playground-default" ...
> <action name="ExceptionThrower"...
> <global-exception-mappings>
The DTD warning is giving you the expected *order* of
elements.
d.
____________________________________________________________________________________
Looking for a deal? Find great prices on flights and hotels with Yahoo! FareChase.
http://farechase.yahoo.com/
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Adding global-exception-mappings tag to struts.xml causes SAXParseException
Posted by Anton Pussep <an...@pussep.de>.
Hello,
I created a very simple application in order to test exception handling.
Unfortunately when I add a global-exception-mappings tag to my
struts.xml (see file below) the application is not even deployed
anymore, and here is what Tomcat complains about:
The content of element type "package" must match
"(result-types?,interceptors?,default-interceptor-ref?,default-action-ref?,global-results?,global-exception-mappings?,action*)".
-
file:/opt/tomcat/5.5.23/webapps/playground/WEB-INF/classes/struts.xml:22:15
Well, line 22 is the package closing tag and to me it seems like my
struts.xml matches the DTD very well, in fact I only use an action and a
global-exception-mappings tag inside of the package. The funny thing is
that when I remove the action tag the app is deployed perfectly well, it
just does not have any actions then. I am pretty sure there is something
I do not know/understand yet. Can you tell what the problem might be?
06: <struts>
07: <package name="playground-default" extends="struts-default">
08:
09: <action name="ExceptionThrower"
10: class="action.ExceptionThrower">
11: <result>/exceptionHandling.jsp</result>
12: <result name="input">/exceptionHandling.jsp</result>
13: <result name="error">/error.jsp</result>
14: </action>
15:
16: <global-exception-mappings>
17: <exception-mapping
18: result="error"
19: exception="java.lang.Throwable"/>
20: </global-exception-mappings>
21:
22: </package>
23: </struts>
Best,
Anton
Re: Struts 2 Package Namespace and URL generation
Posted by Richard Sayre <ri...@gmail.com>.
On 7/3/07, Dave Newton <ne...@yahoo.com> wrote:
> --- Richard Sayre <ri...@gmail.com> wrote:
> > How will it know which name space I am referring to?
>
>
> AFAIR it uses the current namespace unless you supply
> a "namespace" attribute.
>
> d.
>
Thank you. I should have triple checked the doumentation. I missed
it when I read through.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Struts 2 Package Namespace and URL generation
Posted by Dave Newton <ne...@yahoo.com>.
--- Richard Sayre <ri...@gmail.com> wrote:
> How will it know which name space I am referring to?
AFAIR it uses the current namespace unless you supply
a "namespace" attribute.
d.
____________________________________________________________________________________
Looking for a deal? Find great prices on flights and hotels with Yahoo! FareChase.
http://farechase.yahoo.com/
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org