SmartUpload su = new SmartUpload();
su.initialize(pageContext);
pageContext变量找不到,并且不能用new PageContext()定义该变量,如何解决呢?
在action中可以这样得到pageContetext对象
import javax.servlet.jsp.JspFactory;
import com.jspsmart.upload.SmartUpload;
SmartUpload su = new SmartUpload();
JspFactory _jspxFactory = JspFactory.getDefaultFactory();
javax.servlet.jsp.PageContext pageContext =
_jspxFactory.getPageContext(
this.getServlet(),
request,
response,
null,
true,
8192,true);
su.initialize(pageContext);
servlet中
public class servletUpload extends HttpServlet
{
private ServletConfig config;
public void destroy() { }
public void doGet(HttpServletRequest httpservletrequest,
HttpServletResponse httpservletresponse)
throws ServletException, IOException { }
protected void doPost(HttpServletRequest httpservletrequest,
HttpServletResponse httpservletresponse)
throws ServletException, IOException
{
SmartUpload smartupload = new SmartUpload();
try
{
smartupload.initialize(getServletConfig(), httpservletrequest, httpservletresponse);
smartupload.upload();
......
}
catch(Exception exception)
{
}
}
public final ServletConfig getServletConfig() { return config; }
public final void init(ServletConfig servletconfig) throws ServletException
{
config = servletconfig;
}