You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@struts.apache.org by lu...@apache.org on 2011/02/22 10:07:43 UTC

svn commit: r1073268 - in /struts/struts2/trunk/apps/blank/src/main: resources/example.xml resources/struts.xml webapp/error.jsp

Author: lukaszlenart
Date: Tue Feb 22 09:07:43 2011
New Revision: 1073268

URL: http://svn.apache.org/viewvc?rev=1073268&view=rev
Log:
Example how to use global exceptions mapping

Added:
    struts/struts2/trunk/apps/blank/src/main/webapp/error.jsp
Modified:
    struts/struts2/trunk/apps/blank/src/main/resources/example.xml
    struts/struts2/trunk/apps/blank/src/main/resources/struts.xml

Modified: struts/struts2/trunk/apps/blank/src/main/resources/example.xml
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/blank/src/main/resources/example.xml?rev=1073268&r1=1073267&r2=1073268&view=diff
==============================================================================
--- struts/struts2/trunk/apps/blank/src/main/resources/example.xml (original)
+++ struts/struts2/trunk/apps/blank/src/main/resources/example.xml Tue Feb 22 09:07:43 2011
@@ -5,7 +5,7 @@
 
 <struts>
 
-    <package name="example" namespace="/example" extends="struts-default">
+    <package name="example" namespace="/example" extends="default">
 
         <action name="HelloWorld" class="example.HelloWorld">
             <result>/example/HelloWorld.jsp</result>

Modified: struts/struts2/trunk/apps/blank/src/main/resources/struts.xml
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/blank/src/main/resources/struts.xml?rev=1073268&r1=1073267&r2=1073268&view=diff
==============================================================================
--- struts/struts2/trunk/apps/blank/src/main/resources/struts.xml (original)
+++ struts/struts2/trunk/apps/blank/src/main/resources/struts.xml Tue Feb 22 09:07:43 2011
@@ -8,12 +8,18 @@
     <constant name="struts.enable.DynamicMethodInvocation" value="false" />
     <constant name="struts.devMode" value="false" />
 
-    <include file="example.xml"/>
+    <package name="default" namespace="/" extends="struts-default">
 
+        <default-action-ref name="index" />
 
+        <global-results>
+            <result name="error">/error.jsp</result>
+        </global-results>
+
+        <global-exception-mappings>
+            <exception-mapping exception="java.lang.Exception" result="error"/>
+        </global-exception-mappings>
 
-    <package name="default" namespace="/" extends="struts-default">
-        <default-action-ref name="index" />
         <action name="index">
             <result type="redirectAction">
                 <param name="actionName">HelloWorld</param>
@@ -22,6 +28,8 @@
         </action>
     </package>
 
+    <include file="example.xml"/>
+
     <!-- Add packages here -->
 
 </struts>

Added: struts/struts2/trunk/apps/blank/src/main/webapp/error.jsp
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/blank/src/main/webapp/error.jsp?rev=1073268&view=auto
==============================================================================
--- struts/struts2/trunk/apps/blank/src/main/webapp/error.jsp (added)
+++ struts/struts2/trunk/apps/blank/src/main/webapp/error.jsp Tue Feb 22 09:07:43 2011
@@ -0,0 +1,15 @@
+<%@ page contentType="text/html;charset=UTF-8" language="java" %>
+<%@ taglib prefix="s" uri="/struts-tags" %>
+
+<html>
+<head><title>Simple jsp page</title></head>
+<body>
+    <h3>Exception:</h3>
+    <s:property value="exception"/>
+
+    <h3>Stack trace:</h3>
+    <pre>
+        <s:property value="exceptionStack"/>
+    </pre>
+</body>
+</html>
\ No newline at end of file