struts2获取request对象
使用ServletActionContext 获取HttpServletResponse、HttpServletRequest对象
public String execute() {
try {
HttpServletResponse httpServletResponse =ServletActionContext.getResponse();
httpServletResponse.setContentType("text/html; charset=GBK");
PrintWriter out = httpServletResponse.getWriter();
out.println("true");
out.flush();
out.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
猜你喜欢
转载自it586.iteye.com/blog/1096295
今日推荐
周排行