springboot项目:基于的医疗服务系统jzx3w(java+VUE+Mybatis+Maven+Mysql)

一、项目运行
环境配置:
Jdk1.8 + Tomcat8.5 + Mysql + HBuilderX(Webstorm也行)+ Eclispe(IntelliJ IDEA,Eclispe,MyEclispe,Sts都支持)。
项目技术:
Springboot + mybatis + Maven + Vue 等等组成,B/S模式 + Maven管理等等。
环境需要
1.运行环境:最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论上也可以。
2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA;
3.tomcat环境:Tomcat 7.x,8.x,9.x版本均可
4.硬件环境:windows 7/8/10 1G内存以上;或者 Mac OS;
5.是否Maven项目: 否;查看源码目录中是否包含pom.xml;若包含,则为maven项目,否则为非maven项目 
6.数据库:MySql 5.7/8.0等版本均可;


技术栈
1. 后端:Springboot mybatis
2. 前端:vue+css+javascript+jQuery+easyUI+highcharts


使用说明
1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件;
2. 使用IDEA/Eclipse/MyEclipse导入项目,修改配置,运行项目;
3. 将项目中applicationContext.xml配置文件中的数据库配置改为自己的配置,然后运行;
4. 运行成功后,在浏览器中输入:http://localhost:8080/


 

 

 

 

package Main;

import java.sql.*;

public class JDBC {
    public static void main(String[] args) throws SQLException, ClassNotFoundException {
//        1.加载驱动
        Class.forName("com.mysql.cj.jdbc.Driver");
//        2.用户信息和url
        String url = "jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=utf8&useSSL=true";
        String username="root";
        String password="root";
//        3.连接成功,数据库对象 Connection
        Connection connection = DriverManager.getConnection(url,username,password);
//        4.执行SQL对象Statement,执行SQL的对象
        Statement statement = connection.createStatement();
//        5.执行SQL的对象去执行SQL,返回结果集
        String sql = "SELECT *FROM studentinfo;";
        ResultSet resultSet = statement.executeQuery(sql);
        while(resultSet.next()){
            System.out.println("SNo="+resultSet.getString("SNo"));
            System.out.println("SName="+resultSet.getString("SName"));
            System.out.println("Birth="+resultSet.getString("Birth"));
            System.out.println("SPNo="+resultSet.getString("SPNo"));
            System.out.println("Major="+resultSet.getString("Major"));
            System.out.println("Grade="+resultSet.getString("Grade"));
            System.out.println("SInstructor="+resultSet.getString("SInstructor"));
            System.out.println("SPwd="+resultSet.getString("SPwd"));
        }
//        6.释放连接
        resultSet.close();
        statement.close();
        connection.close();
    }
}

 

 

 

package net.amag.util;

import java.util.ArrayList;

import java.util.Collection;

import java.util.Vector;

public class Paging {

/**

* 分页

* @author Etwo

*/

/*

* 分页要素:

* 1、首页first

* 2、最后一页last

* 3、页总数pageCount

* 4、总共显示的数据条数rowCount

* 5、每页显示的数据条数pageRowCount

* 6、当前页curPage

* 7、得到的数据data

*/

/**

* 1、首页first

*/

private int first;

/**

* 2、最后一页last

*/

private int last;

/**

* 3、页总数pageCount

*/

private int pageCount;

/**

* 4、总共显示的数据条数rowCount

*/

private int rowCount;

/**

* 5、每页显示的数据条数pageRowCount

*/

private int pageRowCount;

/**

* 6、当前页curPage

*/

private int curPage;

/**

* 7、得到的数据data

*/

private Collection data;

/**

* 默认显示10条数据

*/

public Paging(Collection data, int curPage) {

this.data = data;

this.curPage = curPage;

this.pageRowCount = 10;

this.rowCount = data.size();

this.pageCount = (int)Math.ceil((double)this.rowCount / (double)this.pageRowCount);

}

/**

* 自行设置每页显示的条数

*/

public Paging(Collection data, int curPage, int pageRowCount) {

this.data = data;

this.curPage = curPage;

this.pageRowCount = pageRowCount;

this.rowCount = data.size();

this.pageCount = (int)Math.ceil((double)this.rowCount / (double)this.pageRowCount);

}

/**

* 首页取得

* @return

*/

public int getFirst() {

return this.first = 1;

}

/**

* 最后一页取得

* @return

*/

public int getLast() {

return this.last = this.pageCount;

}

/**

* 上一页

* @return

*/

public int previous() {

return (this.curPage > 1) ? this.curPage - 1 : 1;

}

/**

* 下一页

* @return

*/

public int next() {

return (this.curPage < this.pageCount) ? this.curPage + 1 : this.pageCount;

}

/**

* 判断是否是首页

* @return

*/

public boolean isFirst() {

return (this.curPage == 1) ? true : false;

}

/**

* 判断是否是最后一页

* @return

*/

public boolean isLast() {

return (this.curPage == this.pageCount) ? true : false;

}

/**

* 当前要显示的数据取得

* @return

*/

public Collection getData() {

Collection curData = null;

if(data != null) {

//定义每一页开始到最后的显示的行数

int start, end;

start = (this.curPage - 1) * this.pageRowCount;

//判断当前显示的数据是否足以显示一整页

if(start + this.pageRowCount > this.rowCount) {

end = this.rowCount;

} else {

end = start + this.pageRowCount;

}

ArrayList arrayData = null;

Vector vectorData = null;

ArrayList arrayCurData = new ArrayList();

Vector vectorCurData = new Vector();

boolean isArrayData = true;

//判断是属于哪一种集合

if(data instanceof ArrayList) {

arrayData = (ArrayList)data;

isArrayData = true;

} else if(data instanceof Vector) {

vectorData = (Vector)data;

isArrayData = false;

}

//循环得到每一页的数据

for(int i = start; i < end; i++) {

if(isArrayData) {

arrayCurData.add(arrayData.get(i));

} else {

vectorCurData.add(vectorData.get(i));

}

}

if(isArrayData) {

curData = arrayCurData;

} else {

curData = vectorCurData;

}

}

return curData;

}

/**

* 客户端显示的工具条

*/

public String getToolBar(String url) {

String str, temp;

//用于判断url中是否存在?

if(url.indexOf("?") == -1) {

temp = "?";

} else {

temp = "&";

}

str = "

";
str += "";

str += "";

//判断是否是首页

if(isFirst()) {

str += "首页 上一页 ";

} else {

str += "首页 ";

str += "上一页 ";

}

//判断是否是最后一页

if(isLast()) {

str += "下一页 尾页 ";

} else {

str += "下一页 ";

str += "尾页 ";

}

str += " 共" + this.rowCount + "条记录 ";

str += " 转到";

for(int i = 1; i <= this.pageCount; i++) {

//判断是否是当前页,若是,则默认为选中当前页

if(i == curPage)

str += "第" + i + "页";

else

str += "第" + i + "页";

}

str += "

";
return str;

}

}

 


@WebServlet(name = "UploadServlet",value = "/upload")
@MultipartConfig(maxFileSize = 1024*1024*5,maxRequestSize = 1024*1024*50)
public class UploadServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //接收文件
        request.setCharacterEncoding("utf-8");
        response.setContentType("text/html;charset=utf-8");
        Collection<Part> parts=request.getParts();
        String basepath=request.getServletContext().getRealPath("/WEB-INF/upload");
        File dir=new File(basepath);
        System.out.println(dir.getAbsoluteFile());
        if (!dir.exists()){
            System.out.println("创建了文件夹");
            dir.mkdirs();
        }
        //2.遍历集合
        PrintWriter out=response.getWriter();
        if (parts!=null){
            for (Part part : parts) {
                if (part.getSubmittedFileName()==null){
                    System.out.println(part.getName()+":"+request.getParameter(part.getName()));
                }else {
                    String submittedFileName = part.getSubmittedFileName();
                    if (submittedFileName==""){
                        continue;
                    }
                    //兼容的操作
                    String header=part.getHeader("content-disposition");
                    String path = header.substring(header.indexOf("filename=") + 10, header.length() - 1);
                    String filename = path.substring(path.lastIndexOf("\\") + 1);
                    //获取文件的后缀
                    String ext=filename.substring(filename.lastIndexOf(".")+1);
                    List<String> allows= Arrays.asList("jpg","png","bmp");
                    if (!allows.contains(ext)){
                        out.write("文件类型不支持"+filename);
                        return;
                    }
                    //string filename=part.getsubmittenfilename();
                    part.write(UploadUtils.creatNewPath(basepath, filename)+"/"+    UploadUtils.createNewFilename(filename));
                    part.delete();
                    System.out.println("上传成功"+filename);
                    out.write("上传成功"+filename);
                }
            }
        }
 
    }
 
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request, response);
    }




 
import java.io.File;
import java.util.HashMap;
import java.util.UUID;
 
public class UploadUtils {
    public static void main(String[] args) {
        createNewFilename("xxx");
    }
    public static String createNewFilename(String filename){
        String s= UUID.randomUUID().toString().replace("-", "");
        System.out.println(s);
        return s+"-"+filename;
    }
    public static String creatNewPath(String basepath,String filename){
        int hashCode=filename.hashCode();
        int dir1=hashCode&0xf;
        int dir2=(hashCode&0xf0)>>4;
        String newpath=basepath+"/"+dir1+"/"+dir2;
        File dir=new File(newpath);
        if (!dir.exists()){
            dir.mkdirs();
        }
        return newpath;
    }
    public static void listFiles(File dir, HashMap<String,String> map){
        File[] files=dir.listFiles();
        if (files!=null){
            for (File file : files) {
                if (file.isDirectory()){
                    listFiles(dir, map);
                }else {
                    map.put(file.getName(),file.getName().split("_")[1]);
                }
            }
        }
    }
}

更多推荐

springboot项目:基于的医疗服务系统jzx3w(java+VUE+Mybatis+Maven+Mysql)