Spring portlet @ActionMapping usage

回眸只為那壹抹淺笑 提交于 2019-12-03 15:22:52

问题


could please anybody explain, how POST request should be mapped properly ? it is not clear from API documentation.

value should be assigned with the value of the action parameter 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.)

@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.

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.

PLEASE: Take a look at this issue which is also relevant https://stackoverflow.com/questions/4782971/handling-ajax-requests-with-spring-portlet


回答1:


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.




回答2:


javax.portlet.action is the name of the parameter that value() is mapped to. So for a mapping like:

@ActionMapping(value = "addDocOrder")
public void addDocOrder(@ModelAttribute("order").......

Your request should URL should be built like:

<portlet:actionURL>
  <portlet:param name="javax.portlet.action" value="addDocOrder"/>
</portlet:actionURL>


来源:https://stackoverflow.com/questions/4585710/spring-portlet-actionmapping-usage

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!