| 1234567891011121314151617181920212223242526272829303132333435363738 |
- package cn.com.goldenwater.dcproj.utils;
- import cn.com.goldenwater.core.web.BaseResponse;
- import net.sf.json.JSONObject;
- import javax.servlet.http.HttpServletResponse;
- import java.io.PrintWriter;
- public class ReturnUtils {
- /**
- * 输出失败信息
- * */
- public static void responseFail(HttpServletResponse response,String message,int code)throws Exception{
- BaseResponse baseResponse = new BaseResponse();
- baseResponse.setSuccess(false);
- baseResponse.setMessage(message);
- baseResponse.setCode(code);
- JSONObject expire = JSONObject.fromObject(baseResponse);
- response.setCharacterEncoding("UTF-8");
- response.setContentType("text/html;charset=utf-8");
- PrintWriter out = response.getWriter();
- out.print(expire.toString());
- out.flush();
- out.close();
- }
- /**
- * 输出格式化返回数据
- * */
- public static BaseResponse retFileResponse(int code,String message){
- BaseResponse baseResponse = new BaseResponse();
- baseResponse.setSuccess(false);
- baseResponse.setMessage(message);
- baseResponse.setCode(code);
- return baseResponse ;
- }
- }
|