servlet+Hibernate文件下载组件的详细介绍
servlet+Hibernate文件下载组件的详细介绍
如果发现文章中的图片无法显示请点击这里:http://tony-action.blog.sohu.com/18034300.html
前几天用servlet+Hibernate写了一个文件下载的组件,遇到了一些问题比如字符乱码(在我的另一篇文章中进行了详细的讲解),现在将所有的代码和运行结果贴出来,大家分享
1登陆页面
2.正确进入下载页面3.验证错误跳回首页
4.用户注册
5.ShowServlet.java用于显示文件下拉列表(从本地硬盘指定目录中查找文件)
6.对参数编码处理后传送文件
7.用户的验证
8.用户注册
9.User对象
10.Userinf.hbm.xml
11.hibernate.cfg.xml
12.web.xml代码
<?xml version="1.0" encoding="GB2312"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4">
<servlet>
<servlet-name>MailServlet</servlet-name>
<servlet-class>tony.MailServlet</servlet-class>
</servlet>
<servlet>
<servlet-name>ShowSrevlet</servlet-name>
<servlet-class>tony.ShowSrevlet</servlet-class>
</servlet>
<servlet>
<servlet-name>Mail</servlet-name>
<servlet-class>tony.MailServlet</servlet-class>
</servlet>
<servlet>
<servlet-name>UserQueryServlet</servlet-name>
<servlet-class>tony.UserQueryServlet</servlet-class>
</servlet>
<servlet>
<servlet-name>InsertInto</servlet-name>
<servlet-class>tony.InsertInto</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>DemoClass</servlet-name>
<url-pattern>/tony.jsp</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Mail</servlet-name>
<url-pattern>/jsp.mail</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>MailServlet</servlet-name>
<url-pattern>/servlet/MailServlet</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>ShowSrevlet</servlet-name>
<url-pattern>/Show.html</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>UserQueryServlet</servlet-name>
<url-pattern>/User.html</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>InsertInto</servlet-name>
<url-pattern>/InsertInto.jsp</url-pattern>
</servlet-mapping>
</web-app>
运行结果