spring MVC框架下Controller发送JSON格式的数据

@Controller
public class LoginController {    
    @RequestMapping("/login.action")
    public void Login(HttpServletRequest request,HttpServletResponse response) {
            
    String str ="{\"success\":\"true\"}";
    PrintWriter pw = null;
    try {
        pw = response.getWriter();
            pw.write(result);
        pw.flush();
    } catch (IOException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    }
}
 

猜你喜欢

转载自blog.csdn.net/zhw0596/article/details/81483053