SpringMVC根据条件跳转页面或者返回数据类型

@RequestMapping(value = “/test”)
public void testServlet(HttpServletRequest request,
HttpServletResponse response) throws IOException, ServletException {
JSONObject json =new JSONObject();
String ss=”11111”;
if(!”dizhi”.equals(ss)){
json.accumulate(“1”,ss);
response.getWriter().print(json.toString());
}else if(ss==null&&”“.equals(ss)){

        response.sendRedirect("www.baidu.com"); 
    }else { 
        request.getRequestDispatcher("/sspingjiededizhi").forward(request,response); 
    } 
}

你可能感兴趣的:(Spring)