日期:2014-05-20  浏览次数:20778 次

Struts 2.1.2 中codebehind 与 验证框架的问题
我在使用struts2 得codebehind 和zeroconfig的时候。
将struts2 的验证框架加上。
然后问题来了,ERROR org.apache.struts2.dispatcher.Dispatcher - Could not find action or result
我的result是通过注解来配置的。
@Results( {
@Result(name = "xx", value = "xxxxxx", type = ServletActionRedirectResult.class)
})

其他result是通过codebehind的方法规则来找result的。
像input 方法 对应 ActionName-input.jsp

------解决方案--------------------
关注
------解决方案--------------------
关注。。。STRUTS2不熟悉啊
------解决方案--------------------
codebehind在struts2.1中已经被Convention Plugin所替代了,如果学习的话换成Convention Plugin吧

The Convention Plugin is bundled with Struts since 2.1 and replaces the Codebehind Plugin and Zero Config plugins. It provides the following features:

* Action location by package naming conventions
* Result (JSP, FreeMarker, etc) location by naming conventions
* Class name to URL naming convention
* Package name to namespace convention
* SEO compliant URLs (i.e. my-action rather than MyAction)
* Action name overrides using annotations
* Interceptor overrides using annotations
* Namespace overrides using annotations
* XWork package overrides using annotations
* Default action and result handling (i.e. /products will try com.example.actions.Products as well as com.example.actions.products.Index)

The Convention Plugin should require no configuration to use. Many of the conventions can be controlled using configuration properties and many of the classes can be extended or overridden.