package com.demo.action;import java.io.PrintWriter;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpServletRequest;import org.apache.struts2.ServletActionContext;import com.demo.bean.Register;
import com.demo.bean.Users;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;public class CheckUserExistsAction extends ActionSupport{
HttpServletResponse response= (HttpServletResponse) ActionContext
.getContext().get(
org.apache.struts2.StrutsStatics.HTTP_RESPONSE);
private String userName;
private String password;
public String getUserName() {
return userName;
}
public void setUserName(String username) {
this.userName = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String CheckUser() throws Exception{
Register register = new Register();
boolean exists = register.CheckUserExists(this.getUserName());
response.setContentType("text/html; GBK");
PrintWriter out = response.getWriter(); out.print(exists);
return null;
}
@Override
public String execute() throws Exception {
// TODO Auto-generated method stub
return super.execute();
}}为什么程序执行到红色字体部分就不执行了
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpServletRequest;import org.apache.struts2.ServletActionContext;import com.demo.bean.Register;
import com.demo.bean.Users;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;public class CheckUserExistsAction extends ActionSupport{
HttpServletResponse response= (HttpServletResponse) ActionContext
.getContext().get(
org.apache.struts2.StrutsStatics.HTTP_RESPONSE);
private String userName;
private String password;
public String getUserName() {
return userName;
}
public void setUserName(String username) {
this.userName = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String CheckUser() throws Exception{
Register register = new Register();
boolean exists = register.CheckUserExists(this.getUserName());
response.setContentType("text/html; GBK");
PrintWriter out = response.getWriter(); out.print(exists);
return null;
}
@Override
public String execute() throws Exception {
// TODO Auto-generated method stub
return super.execute();
}}为什么程序执行到红色字体部分就不执行了
解决方案 »
- mysql 远程批量插入速度很慢,求解
- 关于利用缓存解决海量数据大并发量访问的问题
- hibernate的dao的session问题!!!
- 关于jsp和servlet的问题?
- 求jtds-1.2.2.jar。。。。。
- html:javascript标签报告异常,急
- Hibernate 如何映射
- 我的第一个Servlet编译问题,往高手指点!!
- 问一个hibernate查询方面的问题,请了解相关内容的高手解答
- EJB发布疑问:The DataSource is not a TXDataSource???
- 使用struts2 的标签 <s:fielderror/>默认换行,不换行怎么办
- 再发一贴球ext combo取值问题
报什么异常?这一行有点小问题。
一般写
response.setContentType("text/html");
response.setCharacterEncoding("GBK");
.getContext().get(org.apache.struts2.StrutsStatics.HTTP_RESPONSE);
这样写总感觉不太什么,为啥不用ActionSupport自带的getResponse() 呢?