How do you override Struts 2 Messages?

跟風遠走 提交于 2019-12-05 15:15:48

hehe, you rly sticked on this question. it seems pretty simple.

Check out the example here: http://struts2-by-ash.blogspot.com/2012/06/override-struts-2-messages.html

best, j

Source Overriding Struts Default Properties

The framework uses a number of properties that can be changed to fit your needs. To change any of these properties, specify the property key and value in an struts.properties file. The properties file can be locate anywhere on the classpath, but it is typically found under /WEB-INF/classes

When you are redirecting error messages will be gone. Because you were invoking new action to handle this situation struts2 providing messageStoreInterceptor.

Source MessageStoreInterceptor

Note: I'm here pointing to older version of struts so if you were using latest version change the version in url.

Use <s:actionerror /> tag in JSP to print the error.

Firstly, This error comes into picture if you are trying to upload a file more than the file size you specified for struts.multipart.maxSize

There's a pretty easy solution: In your struts.xml, increase the file size value of struts.multipart.maxSize,

  <constant name="struts.multipart.maxSize" value="50777216000" />
  <param name="maximumSize">15728640</param>

Keep param name="maximumSize" value less than struts.multipart.maxSize value, As in above case, you will get your customised error defined in global.properties unless you exceed struts.multipart.maxSize limit..so try to keep struts.multipart.maxSize value to some high range.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!