I want to use both code-behind and convention plugin in my struts2(2.3.15.3) application. I have tried configuring it. Code behind is working as before, but convention based actions are not working as expected (404 error could not find the mapping). So, debugged through some of struts code and found that it loads both plugins code behind and convention at startup and builds action mappings of all action classes organized by packages into a common object of type RuntimeConfiguraion.

Wanted to step-back and ask a question, does struts by default support usage of both the code-behind and convention plugins at the same time? Is there any specific configuration I need to go through apart from documentation at, http://struts.apache.org/release/2.1.x/docs/convention-plugin.html ?

I am not using struts2-rest-plugin.

有帮助吗?

解决方案

It seems it is possible to have both the plugins as long as we have our actions configured using both versions of @Action annotations. One for code-behind and another for convention plugin. Convention plugin supported urls started working after I added below setting in struts.xml. It seems by default convention plugin excludes all jar files from the classpath when it scans for Action classes.

<constant name="struts.convention.action.includeJars" value=".*?-web-lib-.*?jar(!/|/)?"/>
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top