解决方案 »
- 如何使用HibernateTemplate 的find方法进行多个条件查询
- 关于把代码应用到JAVA界面问题
- 【推荐】怎么写个oracle自动备份脚本,高分等待。
- sqlserver 存储过程返回结果集在jdbc中调用无效
- 在使用hibernate自动产生的映射文件和java类文件中,java类文件中的包提示找不到。在线等、、、
- 用java的axis,axis2,xfire调用.net 的webservice,总是报“服务器无法处理请求 > 无效会话 ”,这是怎么回事?
- jfree出现错误,怎么解决?在线等,答完给分。
- Struts2 s:datetimepicker
- 高分! 求J2EE的背景知识!
- 访问SQL server与Oracle数据库的,JAVA包,那里有下载?急!!高分相送!!!
- HashMap中存储数据,取出来顺序为何全部改变了?
- spring和hibernate问题,如有哪位大虾帮助分析解决,立即送分
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
import com.jspsmart.upload.*;public class servletUpload extends HttpServlet {
private static final String CONTENT_TYPE = "text/html; charset=GBK";
private ServletConfig config;
//Initialize global variables
public void init(ServletConfig config) throws ServletException {
this.config=config;
} //Process the HTTP Get request
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setContentType(CONTENT_TYPE);
PrintWriter out = response.getWriter();
out.println("<html>");
out.println("<head><title>servletUpload</title></head>");
out.println("<body bgcolor=\"#ffffff\">");
out.println("<H1>jspSmartUpload:Servlet Sample</H1>");
out.println("<HR><BR>");
out.println("The method of the HTML form must be POST.");
out.println("</body></html>");
} //Process the HTTP Post request
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
PrintWriter out = response.getWriter();
out.println("<HTML>");
out.println("<BODY bgcolor=\"#ffffff\">");
out.println("<h1>jspSmartUpload:Servlet Sample</h1>");
out.println("<HR>");
//变量定义
int count=0;
SmartUpload mySmartUpload=new SmartUpload();
try{
//初始化
mySmartUpload.initialize(config,request,response);
//上载
mySmartUpload.upload();
//保存上载文件到指定目录,PATH为form表单提交过来的
count=mySmartUpload.save(mySmartUpload.getRequest().getParameter("PATH"));
//显示处理结果
out.println(count+" file uploaded.");
}catch(Exception e){
out.println("Unable to upload the file.<br>");
out.println("Error:"+e.toString());
}
out.println("</BODY>");
out.println("</html>");
} //Clean up resources
public void destroy() {
}
}<%@ page contentType="text/html; charset=GBK" %>
<html>
<head>
<title>
file upload
</title>
</head>
<body bgcolor="#ffffff">
<font size="5" color="#FF0000">
<b>文件上传-使用jspmart upload组件
</b>
</font><br />
<!--enctype属性的值必须为multipart/form-data,method属性的值必须为post,否则不能实现上传功能-->
<form name="selectfile" enctype="multipart/form-data" method="POST" action="/myweb/servletupload">
<p>文件名称:
<input type="file" name="ulfile" size="20" maxlength="80" />
</p>
<p>存储路径:
<input type="text" name="PATH" size="30" maxlength="50"/>
</p>
<p>
<select name="aa" size=10/>
</p>
<p>
<input type="submit" value="上传" />
<input type="reset" value="清除"/>
</p>
</form>
</body>
</html>