自己写的代码

/**
* 转发
* @throws Exception
*/
@RequestMapping(value="red", method= {RequestMethod.GET, RequestMethod.POST})
public void re(User user,HttpServletRequest request, HttpServletResponse response) throws Exception {
User u=new User();
u.setCode(user.getCode());
u.setUsername("18390854368");
u.setName("ywb");
u.setUserpsw("123456");

//1、使用JSONObject
JSONObject json = JSONObject.fromObject(u);


String strJson=json.toString();
response.sendRedirect("http://localhost:8080/yushe-api/user/register?params="+strJson);


}

猜你喜欢

转载自www.cnblogs.com/ywb2018/p/9402789.html