浏览 656 次
|
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
|
|
|---|---|
| 作者 | 正文 |
|
最后更新时间:2008-06-05 关键字: struts2.1.2, rest
在使用Struts2.1.2时,发现一个问题
当我使用rest插件时,在struts.xml中配置 <package name="default" extends="struts-default">
<action name="test" class="cn.com.struts.action.IndexController" method="test">
<result name="test">test.jsp</result>
<result name="success">index.jsp</result>
</action>
</package>
Action代码: package cn.com.struts.action;
import com.opensymphony.xwork2.ActionSupport;
public class IndexController extends ActionSupport{
public String index(){
System.out.println("=====================index=======================");
return SUCCESS;
}
public String test(){
System.out.println("=====================test=======================");
return "test";
}
}
结果浏览http://localhost:8080/struts/test.do时发现不是访问的IndexAction的test方法。 访问的是index方法。返回jsp页面index.jsp 只能通过http://localhost:8080/struts/index!test.do来访问,返回jsp页面index-test.jsp 当然,去掉其rest插件就不会有问题。 这样好像有些不太爽。 声明:JavaEye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
|
|
| 返回顶楼 | |
|
最后更新时间:2008-06-04
不就应该这样吗?
|
|
| 返回顶楼 | |
|
最后更新时间:2008-06-04
我是说它应该两种实现都支持啊。
支持了rest, 结果导致配置action指定action的method方式就不支持了。 看了一下rest插件的源码。 mapping的method为null,然后设为默认的index 看来用rest时设置method是无效的 |
|
| 返回顶楼 | |
|
最后更新时间:2008-06-05
你看下rest插件的plugin.xml里面怎么配的吧,他重写了一个自己的actionmapper,整套的pageflow等都重写过,印象中在文档中看到过可以配置一个CompositeActionMapper的,可以试试
|
|
| 返回顶楼 | |
|
最后更新时间:2008-06-05
通过更改RestActionInvocation.java的源码,实现了我的需求。 protected String invokeAction(Object action, ActionConfig actionConfig) throws Exception {
String methodName = proxy.getMethod();
if(actionConfig.getMethodName()!=null&&actionConfig.getMethodName().trim().length()>0){
methodName =actionConfig.getMethodName();
}
..........................
}
|
|
| 返回顶楼 | |





