java Spring portlet @ActionMapping 用法
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4585710/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Spring portlet @ActionMapping usage
提问by lisak
could please anybody explain, how POST request should be mapped properly ? it is not clear from API documentation.
任何人都可以解释一下,应该如何正确映射 POST 请求?API文档中不清楚。
value should be assigned with the value of the action parameter javax.portlet.action
value 应该与 action 参数 javax.portlet.action 的值一起分配
@ActionMapping(value = "addDocOrder")
public void addDocOrder(@ModelAttribute("order").......
AND next we have "params" (JAVADOC: The parameters of the mapped request, narrowing the primary mapping.)
接下来我们有“params”(JAVADOC:映射请求的参数,缩小主映射的范围。)
@ActionMapping(params = "action=addDocOrder")
public void addDocOrder(@ModelAttribute("order").......
JAVADOC for value() parameter of annotation: The name of the action, according to the Portlet 2.0 "javax.portlet.action" parameter. If not specified, the method will be used as default handler: i.e. for action requests where no specific action mapping was found. Note that all such annotated action methods only apply within the @RequestMapping constraints of the containing handler class.
JAVADOC for value() 注解参数:动作的名称,根据Portlet 2.0的“javax.portlet.action”参数。如果未指定,则该方法将用作默认处理程序:即用于未找到特定操作映射的操作请求。请注意,所有此类带注释的操作方法仅适用于包含处理程序类的 @RequestMapping 约束。
I absolutely don't get what is the point of the existence of the "value" annotation parameter. it has afaik no sense in being there ...it is meant to be the primary mapping, params the secondary one, but {params = "action=addOrder"} makes "value" redundant.
我绝对不明白“值”注释参数存在的意义何在。它在那里没有任何意义......它应该是主要映射,参数是次要映射,但是 {params = "action=addOrder"} 使“值”变得多余。
PLEASE: Take a look at this issue which is also relevant https://stackoverflow.com/questions/4782971/handling-ajax-requests-with-spring-portlet
请:看看这个问题,这也是相关的https://stackoverflow.com/questions/4782971/handling-ajax-requests-with-spring-portlet
回答by Eric
I agree with your assessment as well. The only real advantage I can see when reading the spec is that some special handling in the tag was added. Apparently these two are equivalent:
我也同意你的评价。我在阅读规范时看到的唯一真正优势是在标签中添加了一些特殊处理。显然这两个是等价的:
<portlet:actionURL>
<portlet:param name="javax.portlet.action" value="addDocOrder"/>
</portlet:actionURL>
<portlet:actionURL name="addDocOrder" />
That is from "PLT.26.2 actionURL Tag" in the spec.
那来自规范中的“PLT.26.2 actionURL Tag”。
回答by Eric
javax.portlet.action is the name of the parameter that value() is mapped to. So for a mapping like:
javax.portlet.action 是 value() 映射到的参数的名称。所以对于像这样的映射:
@ActionMapping(value = "addDocOrder")
public void addDocOrder(@ModelAttribute("order").......
Your request should URL should be built like:
你的请求应该 URL 应该像这样构建:
<portlet:actionURL>
<portlet:param name="javax.portlet.action" value="addDocOrder"/>
</portlet:actionURL>