struts-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Adrian CHIA <adri...@dbs.com>
Subject RE: Exception Mapping Annotation seems not inhierted
Date Wed, 27 Jul 2016 07:40:37 GMT
Hi Łukasz



Sorry I meant to say that result mappings defined in the base class are being "inherited"
 in the child class. I believe the framework actually will look for the result in the parent
class if it cannot be found in itself. Anyway I updated the ExceptionMapping annotation with
@Inherited so that my actions which extends this base class will inherit the exception handling.



Alternatively, I tried defining the global exceptions handling in the struts xml however it
seems I cannot get it working together with annotation configurations. Information as listed
below.



I defined this in the struts.xml



<package name="default" extends="struts-default">

<global-results>

    <result name="exception">/ error/error.jsp</result>

    <result name="runtime_exception"> /error/error.jsp</result>

    <result name="error"> error/error.jsp</result>

</global-results>

<global-exception-mappings>

    <exception-mapping exception="java.lang.Exception" result="exception"></exception-mapping>

    <exception-mapping exception="java.lang.Error" result="error"></exception-mapping>

    <exception-mapping exception="java.lang.RuntimeException" result="runtime_exception"></exception-mapping>

</global-exception-mappings>

</package>



Then I have this in the package-info



@ParentPackage(value="struts-default")

@Namespace("/dbsweb-forms/personal-loan")



package com.dbs.ploan.action;

import org.apache.struts2.convention.annotation.Namespace;

import org.apache.struts2.convention.annotation.ParentPackage;



In the Configuration Browser Plugin



The global exceptions mapping and result mapping are not listed here and when I hit the action
throwing the exception I did not get to see the error page.

[cid:image001.png@01D1E81C.DD63F960]



With regards

Adrian Chia



-----Original Message-----
From: Lukasz Lenart [mailto:lukaszlenart@apache.org]
Sent: Wednesday, July 27, 2016 2:52 PM
To: Struts Developers List
Subject: Re: Exception Mapping Annotation seems not inhierted



2016-07-26 10:14 GMT+02:00 Adrian CHIA <adrianc@dbs.com<mailto:adrianc@dbs.com>>:

> Hi

>

> It seems that the struts 2.3.4.1 Exception Mapping annotation cannot be inherited by
the sub-classes. I attempted to put the annotation in the base class but the child class is
unable to inherit the exception mapping. However results view can be inherited. Please advise
?



As far I see, it works that way from the very beginning. You can always define global-exception-mappings
in struts.xml. Also what do you mean by that the "results view can be inherited" ?

@Results/@Result are defined without "@Inherited" meta-annotation so they work the same, they
aren't inherited by child classes.





Regards

--

Łukasz

+ 48 606 323 122 http://www.lenart.org.pl/



---------------------------------------------------------------------

To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org<mailto:dev-unsubscribe@struts.apache.org>

For additional commands, e-mail: dev-help@struts.apache.org<mailto:dev-help@struts.apache.org>



CONFIDENTIAL NOTE:
The information contained in this email is intended only for the use of the individual or
entity named above and may contain information that is privileged, confidential and exempt
from disclosure under applicable law. If the reader of this message is not the intended recipient,
you are hereby notified that any dissemination, distribution or copying of this communication
is strictly prohibited. If you have received this message in error, please immediately notify
the sender and delete the mail. Thank you.
Mime
  • Unnamed multipart/related (inline, None, 0 bytes)
View raw message