Spring-portlet POST ajax xmlHttpRequest

2024-01-11

请任何有使用 Spring DispatcherPortlet 处理 post xmlHttpRequests 经验的人告诉我最好的方法是什么?我使用 YUI io 模块和 Jackson Object Mapper 作为示例:

@ResourceMapping(value="stuff")
public void method(ResourceResponse response){
   Person person = new Person();
   person.setWeight(150);
   ObjectMapper mapper = new ObjectMapper();
   try{
      mapper.writeValue(response.getWriter(), person);
      }
   ...
  }

Ajax:

function() {

   var A = AUI();

   A.io("<portlet:resourceURL id="stuff" />", {
      method: 'POST',
      data: {
        description: 'value'
      }
   });
     }

This https://jira.springframework.org/browse/SPR-7344是您可以投票赞成 spring-portlet 环境将具有与常见 spring-mvc 相同的支持的问题。这是 @ResponseBody,将数据转换为 JSON 等。现在据我所知,必须手动完成...

编辑:找出解决方案

请:看一下这个问题,哪个问题表述得更好https://stackoverflow.com/questions/4782971/handling-ajax-requests-with-spring-portlet https://stackoverflow.com/questions/4782971/handling-ajax-requests-with-spring-portlet


你如何构建 URL?我认为您正在创建一个操作 URL,也许它应该是一个渲染 URL。这意味着,而不是<portlet:actionURL/>你应该使用<portlet:renderURL/>.

希望能帮助到你。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Spring-portlet POST ajax xmlHttpRequest 的相关文章

随机推荐