vanseparis 2016-01-26 01:03 采纳率: 0%
浏览 5390

springMVC controller中方法接收参数问题,怎么接收json对象

后台配置及代码

 <bean id="paramMethodResolver" class="org.springframework.web.servlet.mvc.multiaction.ParameterMethodNameResolver">
    <property name="paramName" value="method"></property>
 </bean>
 <!-- 下边配置请求 -->
 <bean name="/busi/userInfo.action" class="com.mxci.busi.control.impl.UserInfoControllerImpl">
        <property name="methodNameResolver">
            <ref bean="paramMethodResolver"/><!-- 引用上边那个方法名称解析器 -->
        </property>
 </bean>

public String regist(HttpServletRequest request, HttpServletResponse response, UserInfo userInfo) {
// TODO Auto-generated method stub
LOGGER.info("[CR]商户注册开始.请求商户信息:"+userInfo);
MxciInsideResult mxciInsideResult = userInfoService.busiCustRegist(userInfo);//调用
//组装响应数据,并初始化进MxciResponseBody里面
MxciResponseServiceImpl mxciResponseService
= new MxciResponseServiceImpl(mxciInsideResult.getRecode(),mxciInsideResult.getReData(),response);
mxciResponseService.response();//响应结果到客户端
mxciResponseService=null;//置空
return null;
}

目前请求地址这样写是可以封装层userId对象的
http://127.0.0.1:8090/mxciBusiness/busi/userInfo.action?method=regist&userId=wangyan&password=900613&certificateId=50022419901231739X&phoneNo=18696668026

请问怎么样修改才能用下边的地址访问能让后台接收到对象呢???
http://127.0.0.1:8090/mxciBusiness/busi/userInfo.action?method=regist&userInfo={"userId": "wangyan888","customerId": "BUSI20160125000001","lastErrorTime": null,"loginDate": null,"loginErrNum": 0,"password": "","phoneNo": "18696668026","reginDate": null,"status": 0,"valiDate":null}

  • 写回答

5条回答

  • dark_guo 2016-01-26 01:25
    关注

    可以以 String 形式去接收,然后用fastjson 去格式化成json对象。 感兴趣可以去看一看fastjson

    评论

报告相同问题?

悬赏问题

  • ¥65 永磁型步进电机PID算法
  • ¥15 sqlite 附加(attach database)加密数据库时,返回26是什么原因呢?
  • ¥88 找成都本地经验丰富懂小程序开发的技术大咖
  • ¥15 如何处理复杂数据表格的除法运算
  • ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)
  • ¥15 有兄弟姐妹会用word插图功能制作类似citespace的图片吗?
  • ¥15 latex怎么处理论文引理引用参考文献
  • ¥15 请教:如何用postman调用本地虚拟机区块链接上的合约?
  • ¥15 为什么使用javacv转封装rtsp为rtmp时出现如下问题:[h264 @ 000000004faf7500]no frame?
  • ¥15 乘性高斯噪声在深度学习网络中的应用