找不到动作,为什么不呢?
Action not found, why not?
我使用如下方法创建了一个动作:
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,但不适用于后两个。
我错过了什么?
value
属性不应包含扩展名。
@Action(value = "index<del>.action</del>",
results = {
@Result(name = ActionSupport.SUCCESS, location = "success.jsp"),
@Result(name = ActionSupport.INPUT, location = "fail.jsp")
})
您也可以尝试 http://my-server.com/public/namespace
,它应该由默认启用的约定 uknown 处理程序处理。
我使用如下方法创建了一个动作:
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,但不适用于后两个。
我错过了什么?
value
属性不应包含扩展名。
@Action(value = "index<del>.action</del>",
results = {
@Result(name = ActionSupport.SUCCESS, location = "success.jsp"),
@Result(name = ActionSupport.INPUT, location = "fail.jsp")
})
您也可以尝试 http://my-server.com/public/namespace
,它应该由默认启用的约定 uknown 处理程序处理。