Struts 2 Writing global results


            Most often, results are nested with the action element. But some results apply to multiple actions. In a secure application, a client might try to access a page without being authorized, and many actions may need access to a "logon" result.

            If actions need to share results, a set of global results can be defined for each package. The framework will first look for a local result nested in the action. If a local match is not found, then the global results are checked.


Global result configurations

		<global-results>
			<result name="home">home.jsp</result>
		</global-results>


Complete 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.enable.DynamicMethodInvocation" value="true" />
	<package name="com" extends="struts-default">

		<global-results>
			<result name="home">home.jsp</result>
		</global-results>


		    <action name="*User" method="{1}" class="com.candidjava.controller.UserAction">
            <result name="success">/success.jsp</result>
        </action>  

	</package>
</struts>


Screenshot

                        

           


Download

        Struts 2 global results war

        Struts 2 global results maven zip



Related Post

Comments


©candidjava.com