Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The best option is to remove the Struts REST plugin when not used. Alternatively you can only upgrade the plugin by dropping in all the required JARs (plugin plus all dependencies).  Another options is to limit th plugin to server normal pages and JSONs only:

  1. Disable handling XML pages and requests to such pages

    Code Block
    xml
    xml
    <constant name="struts.action.extension" value="xhtml,,json" />
  2. Override getContentType in XStreamHandler

    Code Block
    languagejava
    public class MyXStreamHandler extends XStreamHandler { public String getContentType() {
     return "not-exiting-content-type-@;/&%$#@";
     }
    }
  3. Register the handler by overriding the one provided by the framework in your struts.xml

    Code Block
    xml
    xml
    <bean type="org.apache.struts2.rest.handler.ContentTypeHandler" name="myXStreamHandmer" class="com.company.MyXStreamHandler"/>
    <constant name="struts.rest.handlerOverride.xml" value="myXStreamHandler"/>