Another <s:url> quirk:

In a jsp firstPage.jsp residing in namespace /first if you use a <s:uri>
tag to create an action  url for action go-to-second-page om
namespace /second S2 gives a warning

No configuration found for the specified action:
'/second/go-to-second-page.action' in namespace: '/first'

and fails to find the action.

In short, 
<s:form action="go-to-second-page" namespace="/second" >
...
</s:form>

is not equivalent to 

<s:url id="myURL" action="go-to-second-page" namespace="/second"
includeContext="false" />
<s:form action="%{myURL}" >
        ...
</s:form>
==========================================demo========================

struts.xml:

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
    "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
    "http://struts.apache.org/dtds/struts-2.0.dtd";>
<struts>
        <constant name="struts.devMode" value="true" />
        <constant name="struts.convention.action.disableScanning"
value="true" />

        <package name="one" namespace="/first" extends="struts-default">
                <action name="firstPage">
                        <result>/WEB-INF/content/first/firstPage.jsp</result>
                </action>
        </package>
        <package name="two" namespace="/second" extends="struts-default">
                <action name="go-to-second-page" >
                        <result>/WEB-INF/content/second/success.jsp</result>
                </action>
        </package>

</struts>

===============

/WEB-INF/content/first/firstPage.jsp


<%@ taglib prefix="s" uri="/struts-tags"%>
<html>
        <body>
                <h3>
                        Page 1
                </h3>
                <div>
                        <s:form action="go-to-second-page" namespace="/second" >
                                <s:textfield label="Title" name="title" 
size="30" maxlength="30" />
                                <s:submit value="Go to success page" />
                        </s:form>
                </div>
                <hr/>
                <div>
                        <s:url id="myURL" action="go-to-second-page" 
namespace="/second"
includeContext="false" />
                        <s:form action="%{myURL}" >
                                <s:textfield label="Title" name="title" 
size="30" maxlength="30" />
                                <s:submit value="Go to success page" />
                        </s:form>
                </div>
                
        </body>

</html>

//=====

/WEB-INF/content/second/success.jsp

<html>
        <body>
        <div>
                <h3>
                        Success!!
                </h3>
        </div>
        </body>
</html>

//================

web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
        xmlns="http://java.sun.com/xml/ns/javaee";
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd";
        xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd";
        id="WebApp_ID" version="2.5">
        <display-name>S:URL</display-name>
        <filter>
                <filter-name>struts2</filter-name>
                <filter-class>

org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
        </filter>
        <filter-mapping>
                <filter-name>struts2</filter-name>
                <url-pattern>/*</url-pattern>
        </filter-mapping>

        <welcome-file-list>
                <welcome-file>index.html</welcome-file>
        </welcome-file-list>

</web-app>

//==================
index.html

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
        <head>
            <META HTTP-EQUIV="Refresh" CONTENT="0;URL=first/firstPage">
        </head>

        <body>
                <p>Loading ...</p>
        </body>
</html>

===============
Cheers
Chris



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to