package com.sunmq.action;import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.http.HttpServletResponse;
import com.opensymphony.xwork2.ActionSupport;public class CheckUserAction extends ActionSupport {
private String type;
public String execute() throws IOException {
HttpServletResponse response=null;
response.setContentType("text/html; charset=UTF-8");
PrintWriter out = response.getWriter();
out.print("<script>alert('成功');window.location.reload();</script>");
return SUCCESS;
} public String getType() {
return type;
} public void setType(String type) {
this.type = type;
}}出错如下
type Exception reportmessage description The server encountered an internal error () that prevented it from fulfilling this request.exception java.lang.NullPointerException
com.sunmq.action.CheckUserAction.execute(CheckUserAction.java:23)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:597)
com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:452)
com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:291)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:254)
import java.io.PrintWriter;
import javax.servlet.http.HttpServletResponse;
import com.opensymphony.xwork2.ActionSupport;public class CheckUserAction extends ActionSupport {
private String type;
public String execute() throws IOException {
HttpServletResponse response=null;
response.setContentType("text/html; charset=UTF-8");
PrintWriter out = response.getWriter();
out.print("<script>alert('成功');window.location.reload();</script>");
return SUCCESS;
} public String getType() {
return type;
} public void setType(String type) {
this.type = type;
}}出错如下
type Exception reportmessage description The server encountered an internal error () that prevented it from fulfilling this request.exception java.lang.NullPointerException
com.sunmq.action.CheckUserAction.execute(CheckUserAction.java:23)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:597)
com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:452)
com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:291)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:254)
解决方案 »
- tomcat7.0配置总是失败,求大侠帮忙
- 发布db2view产品,与诸位指点交流,多提意见
- 在jsp中如何做下载?
- 多页面传值问题
- 怎么样提取已经显示在页面中表格的数据
- 为何JSP页面注册成功仍显示错误提示
- 有关UTF字符的问题,会的帮下,急~
- 如何在servlet中提高访问access数据库的速度?
- 请问,去会字符串型的日期,如何转化成datetime型从而写入数据库?如果不转换,能写入吗?(多谢)?
- 求助!mybatis 异常Mapped Statements collection does not contain value for
- Struts2 上传问题,求大侠帮忙!
- 启动tomcat找不到jdk
response.setContentType("text/html; charset=UTF-8");
PrintWriter out = response.getWriter();你的response都还没有值 你就设置setContentType,你说他能不报错不?
去掉还是同样的错误
com.sunmq.action.CheckUserAction.execute(CheckUserAction.java:23)//这句空指针了,在23行。
HttpServletResponse response;
not
HttpServletResponse response=null;