• 大小: 2.65MB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2023-09-05
  • 语言: 其他
  • 标签: 青鸟租房  

资源简介

在北大青鸟学习的时候,自己开发的租房系统,很有学习价值

资源截图

代码片段和文件信息

package action;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.fileupload.FileItem;
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
import org.apache.commons.fileupload.servlet.ServletFileUpload;

import service.IDistrictService;
import service.IHouseService;
import service.IUserService;
import service.impl.DistrictService;
import service.impl.HouseService;
import service.impl.UserService;
import entity.District;
import entity.House;
import entity.Users;
public class AddHouseAction extends HttpServlet{
public AddHouseAction() {
super();
}
public void destroy() {
super.destroy();
}
public void doGet(HttpServletRequest request HttpServletResponse response)throws ServletException IOException {
doPost(request response);
}
public void doPost(HttpServletRequest request HttpServletResponse response)throws ServletException IOException {
IDistrictService ds = new DistrictService();
ArrayList allDistrict = ds.getAllDistrict();
request.getSession().setAttribute(“allDistrict“ ds);
request.getSession().setAttribute(“allDistrict“ allDistrict);   
boolean ckmul = ServletFileUpload.isMultipartContent(request);
if(ckmul){
String filepath = this.getServletContext().getInitParameter(“filepath“);
System.out.println(“---filepath= “+filepath);
String webpath=this.getServletContext().getInitParameter(“webpath“);
System.out.println(“---webpath=“+webpath);
File ftemp = new File(“G:\\temp\\buffer“);
if(!ftemp.exists()){
   ftemp.mkdirs();
}
DiskFileItemFactory df = new DiskFileItemFactory();
                    df.setRepository(ftemp);
                    df.setSizeThreshold(50*1024*1024);//50M
ServletFileUpload   sfu = new ServletFileUpload(df);
                    sfu.setFileSizeMax(500*1024*1024);
String uid=““;
String title=““;
String tid=““;
String floorage=““;
String price=““;
String did=““;
String sid=““;
String contact=““;
String description=““;
String photo=““;
boolean ifupload = true;                  
   try{
      List flist = sfu.parseRequest(request);
      for(FileItem fit:flist){
         if(fit.isFormField()){
         if(fit.getFieldName().equals(“uid“)){
            uid=fit.getString(“UTF-8“);
        }
            if(fit.getFieldName().equals(“title“)){
             title=fit.getString(“UTF-8“);
            }
            if(fit.getFieldName().equals(“tid“)){
             tid=fit.getString(“UTF-8“);
            }
            if(fit.getFieldName().equals(“floorage“)){
             floorage=fit.getString(“UTF

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2016-07-11 16:27  house\
     文件         984  2016-07-11 16:31  house\.classpath
     目录           0  2016-07-26 10:18  house\.myeclipse\
     文件         288  2016-07-08 23:07  house\.mymetadata
     文件        1748  2013-10-28 16:23  house\.project
     目录           0  2016-07-08 23:01  house\.settings\
     文件         500  2013-10-28 16:24  house\.settings\.jsdtscope
     文件         364  2013-10-28 16:24  house\.settings\org.eclipse.jdt.core.prefs
     文件         453  2016-07-11 16:31  house\.settings\org.eclipse.wst.common.component
     文件         252  2013-10-28 16:24  house\.settings\org.eclipse.wst.common.project.facet.core.xml
     文件          49  2013-10-28 16:24  house\.settings\org.eclipse.wst.jsdt.ui.superType.container
     文件           6  2013-10-28 16:24  house\.settings\org.eclipse.wst.jsdt.ui.superType.name
     目录           0  2016-07-08 23:56  house\WebRoot\
     目录           0  2016-07-11 16:33  house\WebRoot\WEB-INF\
     目录           0  2016-07-22 13:58  house\WebRoot\WEB-INF\classes\
     目录           0  2016-07-22 13:58  house\WebRoot\WEB-INF\classes\action\
     文件        6204  2016-07-22 13:58  house\WebRoot\WEB-INF\classes\action\AddHouseAction.class
     文件        1799  2016-07-22 13:58  house\WebRoot\WEB-INF\classes\action\CodeFilter.class
     文件        1604  2016-07-22 13:58  house\WebRoot\WEB-INF\classes\action\DelHouseAction.class
     文件        3637  2016-07-22 13:58  house\WebRoot\WEB-INF\classes\action\HouseAction.class
     文件        2048  2016-07-22 13:58  house\WebRoot\WEB-INF\classes\action\LoginAction.class
     文件        1835  2016-07-22 13:58  house\WebRoot\WEB-INF\classes\action\OneHouseAction.class
     文件        1947  2016-07-22 13:58  house\WebRoot\WEB-INF\classes\action\RegAction.class
     文件        3574  2016-07-22 13:58  house\WebRoot\WEB-INF\classes\action\SearchAction.class
     文件        2774  2016-07-22 13:58  house\WebRoot\WEB-INF\classes\action\SearchStreet.class
     文件        1623  2016-07-22 13:58  house\WebRoot\WEB-INF\classes\action\StreetAction.class
     文件        3113  2016-07-22 13:58  house\WebRoot\WEB-INF\classes\action\UpHouseAction.class
     目录           0  2016-07-22 13:58  house\WebRoot\WEB-INF\classes\dao\
     文件         324  2016-07-22 13:58  house\WebRoot\WEB-INF\classes\dao\IDistrictDao.class
     文件         526  2016-07-22 13:58  house\WebRoot\WEB-INF\classes\dao\IHouseDao.class
     文件         274  2016-07-22 13:58  house\WebRoot\WEB-INF\classes\dao\IStreetDao.class
............此处省略111个文件信息

评论

共有 条评论