分享

java后台重定向post传参及接受重定向post传参

 一本正经地胡闹 2019-08-06

项目中碰到的问题是,我在controller中有重定向传参到另外一个controller,但是接收到的值是乱码    ps:我传的参数是汉字

请教了我们的项目经理,说是那个重定向传参是get方式的请求传参:示例代码

复制代码
return "redirect:/RepaieInfo/goDetail?companyId="+companyId
                        +"&baseNo="+baseNo
                        +"&doorId="+doorId
                        +"&account="+creater
                        +"&id="+idRepair
                        +"&modifier="+modifier
                        +"&workOrderStatus="+"1";
复制代码

后面我改成了post传参: 这个是重定向post传参;

public String add(Map<String, Object> map, RedirectAttributes attributes,
//将有汉字得参数,以post的方式传过去
attributes.addFlashAttribute("descContentV",descContentV);

第二个controller 是要接受我第一个controller传过来的参数

@RequestMapping(value = "/goDetail")
    public String goDetail(HttpServletRequest httpRequest,
            @ModelAttribute("descContentV") String descContentV, //接收第一个controller重定向传过来的参数(post)
            ModelMap model){

后续在进行正常的逻辑

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多