Tuesday, August 3, 2010

Maven: Filtering Delimiter

The "@" is one of the default delimiter of Maven 2. This may cause problem if there is any email address in the resource files to be filtered. To filter resources that contain "@", simply add maven-resources-plugin into the pom file and configure it as follow:



Since Maven 2 uses "${", "}" and "@" as default delimiters, the above configuration removes "@" from delimiters and hence will filter resources that contains "@" without a problem.

Struts 2: Change the default file size to upload.

In Struts 2, the default maximum file size to upload is 2 MB. To change this, simply create a property file "struts.properties" under the classpath and add the following key/value pair into it:



(This example changes the maximum file size to 10,240,000 bytes.)

Monday, August 2, 2010

Can Struts 1 & 2 coexist in the same web application?

The answer is yes, but in the web.xml file the Struts 1 servlet mapping and Struts 2 filter mapping need to be configured as follow so that Struts 1 and 2 will not be invoked on the same request:

Struts 1:
<servlet-mapping/>
   <servlet-name>action</servlet-name>
   <url-pattern>*.do</url-pattern>
</servlet-mapping>

Struts 2:
<filter-mapping>
   <filter-name>struts</filter-name>
   <url-pattern>*.action</url-pattern>
</filter-mapping>
Note that there is no slash before *.action in url-pattern element.