I think the message customisation has been covered so onto trapping
interceptor results.

The easiest way you can trap a 500 error is to define the following XML in
your web.xml file,

  <error-page>
        <error-code>500</error-code>
        <location>/error.jsp</location>
    </error-page>

In your error page, you will have access to the actionErrors collection
which will be populated by the FileUploadInterceptor.


Laurie Harper wrote:
> 
> Mike J. M. wrote:
>> Hello,
>> 
>> 
>> So I am currently using Struts, including an action that has a fileUpload
>> Interceptor that checks for files that are too large and certain
>> allowable
>> file types. Right now if either of these conditions are met, the system
>> will
>> throw a generic HTTP 500 error up. What I am wondering is how to
>> customize
>> this.
>> 
>> 
>> in the docs:
>> http://struts.apache.org/2.0.6/struts2-core/apidocs/org/apache/struts2/interceptor/FileUploadInterceptor.html
>> 
>> i found these messages that i can supposedly customize. however, the doc
>> does not specify WHERE i am supposed to put these error messages at, and
>> furthermore, after looking at the source code for FileUploadInterceptor,
>> I
>> found that these messages are printed to the log file, and it doesn't
>> look
>> like it prints to the actual HTML.
>> 
>> 
>> * struts.messages.error.uploading - a general error that occurs when the
>> file could not be uploaded
>> 
>> 
>> * struts.messages.error.file.too.large - occurs when the uploaded file is
>> too large
>> 
>> 
>> * struts.messages.error.content.type.not.allowed - occurs when the
>> uploaded
>> file does not match the expected content types specified
>> 
>> 
>> The doc says that these error messages originate from
>> struts-messages.properties. I'm guessing that's in the struts.jar itself
>> because I don't see it anywhere else, so am I supposed to modify that
>> directly? I'm a little bit iffy about doing that.
> 
> It's not obvious from the documentation, but the message come from the 
> 'global message resources', which you configure via the 
> struts.custom.i18n.resources property in struts.properties. The 
> struts=messages.properties file mentioned is where the standard defaults 
> are stored.
> 
> So, create a resource bundle containing your customized error messages, 
> say my-struts-messages.properties, and place it in the classpath, then 
> add a struts.custom.i18n.resources=package.name.my-struts-messaes 
> property to your struts.properties configuration.
> 
>> So, in a nutshell, how do I catch an Interceptor error and make it
>> redirect
>> to a nice page instead of the generic HTTP 500 page? Actually, what would
>> be
>> better is to redirect to an action while passing into it a parameter
>> "message" that will contain error messages. Then, in the JSP i want to do
>> <s:property ...> to grab that message.
> 
> I'm not sure about this part. I would expect, assuming you implement 
> ValidationAware (e.g. by extending from ActionSupport), that you would 
> get a validation failure rather than a status 500 response. If you're 
> still experiencing that, post the corresponding error logs and stack
> trace.
> 
> L.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Struts%2C-Interceptor-error-message-customization-tp15189228p15518568.html
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to