java 类中HttpServletRequest request为空 困惑
packagelee;importjava.io.*;importjavax.servlet.http.HttpServletRequest;importorg.apac...
package lee;
import java.io.*;
import javax.servlet.http.HttpServletRequest;
import org.apache.struts2.ServletActionContext;
public class CreateImage
{
private HttpServletRequest req;
public CreateImage(int width,int height,double a[])
{
... //代码
}
public void drawCurve() throws IOException{
req = ServletActionContext.getRequest();
if(req==null){
System.out.println("null");
}else
{
System.out.println("ok");
}
}
}
相当困惑 得到的req就是为null 求解释 展开
import java.io.*;
import javax.servlet.http.HttpServletRequest;
import org.apache.struts2.ServletActionContext;
public class CreateImage
{
private HttpServletRequest req;
public CreateImage(int width,int height,double a[])
{
... //代码
}
public void drawCurve() throws IOException{
req = ServletActionContext.getRequest();
if(req==null){
System.out.println("null");
}else
{
System.out.println("ok");
}
}
}
相当困惑 得到的req就是为null 求解释 展开
展开全部
private HttpServletRequest req; 这个不要改成
HttpServletRequest request = ServletActionContext.getRequest();
就可以了!
HttpServletRequest request = ServletActionContext.getRequest();
就可以了!
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询