找不到操作,为什么不



我用如下方法创建了一个操作:

public class NomenclatureAction extends ActionSupport {
    // ...
    @Actions({
      @Action(value = "ajaxDoStuff",
              results = {
                    @Result(name = ActionSupport.SUCCESS, location = "success.jsp"),
                    @Result(name = ActionSupport.INPUT, location = "fail.jsp") 
              }),
      @Action(value = "index.action",
              results = {
                    @Result(name = ActionSupport.SUCCESS, location = "success.jsp"),
                    @Result(name = ActionSupport.INPUT, location = "fail.jsp") 
              })
    })
    public final String doStuff() {
        // ...
        return ActionSupport.SUCCESS;
    }
}

我想使用以下 URL 之一调用相同的方法doStuff

  • http://my-server.com/public/namespace/ajaxDoStuff
  • http://my-server.com/public/namespace/ajaxDoStuff.action
  • http://my-server.com/public/namespace/index
  • http://my-server.com/public/namespace/index.action

到目前为止,它适用于前两个 URL,但不适用于后两个 URL。
我错过了什么?

value 属性不应包含扩展名。

@Action(value = "index.action",
  results = {
        @Result(name = ActionSupport.SUCCESS, location = "success.jsp"),
        @Result(name = ActionSupport.INPUT, location = "fail.jsp") 
  })

您还可以尝试http://my-server.com/public/namespace哪些应该由约定 uknown 处理程序处理,默认情况下该处理程序处于启用状态。

相关内容

  • 没有找到相关文章

最新更新