The development process of Java graduation project

How to use Java code to make a graduation design system that meets the needs of college students?

This article is for learning purposes only, and it is intended to help some students who have the same university experience as me. I write this article with two main ideas: 1.
Students who have not graduated and are still in the beginning of school, I hope this article The article allows you to clarify your own direction, choose your favorite major and direction, and work hard to learn this knowledge through four years of college time, whether it is java or testing, C#, C++ and other computer majors, as long as you are interested , just stick to it.
2. For students who have not graduated but are still in the graduation period, I hope this article can lead you to complete the graduation project and learn Java programming from this systematic operation.
Solemnly declare: This article is only for learning, do not use for commercial purposes, offenders will bear the consequences at their own risk!
Supplementary note: All the teaching content in this article is based on a certain Java foundation, and the content of the article is limited. If you have any doubts, you can add WeChat f2468433277 for detailed consultation.
1. Preliminary preparation
A Java graduation design system that meets the needs of the school requires the following development environment and tools:
1. jdk. (jdk is a necessary development environment for Java development, and the version can be freely selected. Here, jdk1.7 is used as a demonstration version. The installation tutorial can be searched online, and can be found on the entire network.) 2. mysql
. (Mysql is a kind of database. In Java development, most of them use mysql as the data storage center. Please choose the version yourself. Installation tutorials can be found online. There is a small gap between each version. It is recommended to use one version to the end. Here is mysql5.7 is the demonstration version.)
3. tomcat. (The version is free to choose, and it is recommended to use the non-installation version. Here, tomcat8.5 is used as the demonstration version.)
4. Maven. (Because most of the graduation projects are large-scale management systems, the teaching here is to create a maven project, so maven is needed, and it is recommended to use a non-installed version. Here, maven3.5 is used as a demonstration version. If you want to know more about maven, You can check it online, so I won’t explain it here.)
Tip: With the first article, you can directly write Java code through the txt file and run it in the cmd window. With the second article, you can use Java code to complete the interaction with the database. Below are a few auxiliary tools that can be more helpful You write code quickly.
5. idea editor. (Since what I have learned is the idea editor, I use idea as a demonstration tool here. If you use the eclipse editor, the related operations will be different. You can just look at the code part.) 6. sqlYog or Navicat
. (Database visualization tools, building databases and tables can directly skip the code part, simplify the programming process, and improve programming efficiency.) The
last two programs can be downloaded online, and it is recommended to use certain operations to complete free use.
2. Design and build a database
Before developing, don’t rush to write code. First, think about what your system should look like, that is, what functions it contains, and divide the corresponding data tables according to these functions. Due to the limitations of the article, here I Take a dry cleaner management system that I have made as an example to explain.
First of all, because it is a management system, we need to have registration and login functions, so we need a user table, and we need to manage the clothes, so we need a clothes table, and the clothes need to be checked for quality problems, so we need a check clothes information Clothes have a state when they are washed, so a laundry table is needed, and clothes need to be stored in the warehouse after washing, so an inventory table is needed. According to this idea, the database is designed, each table is associated with a specific field, and the next step is started after the table is built.
3. Looking for a framework
In the Java development process, we must first clarify what project we want to develop, what architecture to use, whether it is C/S or B/S. In layman's terms, C/S is the client type, and B/S is the web version. The currently popular ones are basically B/S architectures, so you need a Java background framework and a beautiful front-end framework.
As a college student, if you want to design a front-end page with a beautiful interface, you need strong front-end development capabilities and a lot of time, so here I suggest that you find a complete front-end framework on the Internet and modify it yourself. Elegant, but also saves time.
In addition, there are many popular Java back-end frameworks on the market at present, and most of the students who study in universities are SSH. This form has already been eliminated, and it is difficult to find teaching tutorials on the Internet, which is not suitable for the mainstream of society. The SSM framework is more suitable for the graduation project of college students. It is light and simple, stable and efficient. SpringBoot distributed is not recommended for college students. It covers a wide range of knowledge. If you are a college student who has just entered school, I suggest you study hard from beginning to end. But if you are a student who is about to graduate, I suggest you not contact it first. First, it will affect the development of your graduation project, and second, it will disturb your understanding of development. After you understand and learn other frameworks of Java, you can learn about it.
There is a pure version of the SSM project in my download resources, download it and use it!
Fourth, the code part
Next, we enter the topic - the code part.
First, we download the SSM pure version framework and open it through idea. The operation steps are shown in the figure below:
insert image description here
Select the project to be decompressed after downloading:
insert image description here
select these two here, and the rest will be Next:
insert image description here
Next, find maven in the File—>settings of idea, and complete the following configuration:
insert image description here
Create according to the database field Entity class:
insert image description here
The content of the article is limited. Here we take the data display function as an example to give a detailed introduction:
1. Create the jsp front-end page code (here you can modify the front-end framework downloaded from the Internet)

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<html>
<head>
    <title>Title</title>
    <script src="/js/jquery-3.3.1.min.js"></script>
</head>
<body>
<%--1.条件查询--%>
<form  id="myForm" action="/emp/show" method="post" style="text-align: center">
    姓名:<input type="text" name="name" value="${page.name}">

    生日:<input type="date" name="startBirth"  value="<fmt:formatDate value='${page.startBirth}' pattern='yyyy-MM-dd'/>" >-
    <input type="date" name="endBirth" value="<fmt:formatDate value='${page.endBirth}' pattern='yyyy-MM-dd'/>" >
    部门:<select name="deptId" >
    <option value="0">--请选择--</option>
    <c:forEach var="dept" items="${depts}">
        <option value="${dept.did}"
                <c:if test="${dept.did==page.deptId}">selected=true</c:if>
        >${dept.dname}</option>
    </c:forEach>
</select>
    <input type="hidden" id="pageNum" name="currPage" value="1">
    <input type="submit" value="搜索">
</form>
<%--2.数据展示--%>
<table  align="center" cellpadding="15" cellspacing="0" border="1">
    <tr>
        <td><input type="checkbox" id="checkAll">全选</td>
        <td>编号</td>
        <td>姓名</td>
        <td>年龄</td>
        <td>性别</td>
        <td>生日</td>
        <td>津贴</td>
        <td>工资</td>
        <td>部门</td>
        <td>大头贴</td>
        <td><input type="button" id="batchDel" value="批量删除">| <input type="button" onclick="location.href='/emp/add1'" value="新增"></td>
    </tr>
    <c:if test="${not empty list}">
        <c:forEach var="emp" items="${list}">
            <tr>
                <td><input class="checkNow" value="${emp.id}" type="checkbox"></td>
                <td>${emp.id}</td>
                <td>${emp.name}</td>
                <td>${emp.age}</td>
                <td>${emp.sex}</td>
                <td><fmt:formatDate value="${emp.birth}" pattern="yyyy-MM-dd"/></td>
                <td>${emp.bonus}</td>
                <td>${emp.salary}</td>
                <td>${emp.dept.dname}</td>
                <td><a href="/emp2/down?fname=${emp.imgurl}"><img src="${emp.imgurl}" alt="" width="120px" height="120px"></a></td>
                <td><a href="/emp/deleteById/${emp.id}">删除</a>|
                    <a href="/emp/update1/${emp.id}">修改</a></td>
            </tr>
        </c:forEach>
    </c:if>
</table>
<%--3.分页--%>

<table align="center" cellpadding="10" cellspacing="10" border="1">
    <tr>
        <td><a href="javascript:goPage(1)">首页</a></td>
        <td><a href="javascript:goPage(${page.currPage-1})">上一页</a></td>
        <c:forEach var="i" begin="1" end="${page.totalPage}">
            <td><a href="javascript:goPage(${i})">${i}</a></td>
        </c:forEach>
        <td><a href="javascript:goPage(${page.currPage+1})">下一页</a></td>
        <td><a href="javascript:toPage()">跳转</a>到第<input size="2" type="text" value="${page.currPage}" id="go">页</td>
        <td><a href="javascript:goPage(${page.totalPage})">尾页</a></td>
    </tr>
</table>

<!--js部分-->
<script>

    $("#batchDel").click(function () {
        //1.获取到选中的ids  2.ids数组 送到后台
        var ids=new Array();
        $(".checkNow:checked").each(function () {
            var id=$(this).val()
            ids.push(id);
        });
        $.post("/emp2/batDel",{ids:ids.toString()},function (data) {
            location.href="/";
        });
    });

    //prop和attr的区别?
//实现全选和全不选
    $("#checkAll").click(function () {
        if($(this).prop("checked")){
            $(".checkNow").prop("checked",true)
        }else {
            $(".checkNow").prop("checked",false)
        }
    });

    function goPage(page) {
        var total=${page.totalPage};

        if(page>total){
            page=total;
        }
        if(page<1){
            page=1;
        }

        $("#pageNum").val(page);
        $("#myForm").submit()
    }
    function toPage() {
        var page=$("#go").val();
        goPage(page)
    }
</script>

</body>
</html>

2. Write the background code. The Java project is divided into a three-layer structure, including the controller layer Controller, the service layer Service layer, and the service layer mapper layer, also called the dao layer. Take the display code as an example, now list them one by one:
(1), control layer

@RequestMapping("/show")
    public ModelAndView show(PageBean page, ModelAndView mav){
    //取 调 存 转

    //查询所有的部门--show.jsp中下拉框展示所有的部门
    List<Dept> depts=service.selectDepts();
    //模糊分页条件查询员工
    List<Emp> list=service.show(page);

    //存  depts list  page
    mav.addObject("depts",depts);
    mav.addObject("list",list);
    mav.addObject("page",page);
    //转
    mav.setViewName("show");
    return mav;
    }

The code needs to be combined with the department table for data processing, so the code looks cumbersome, but the data display can be simplified. @RequestMapping("/show") corresponds to the front-end path, which is a necessary path for front-end and back-end interaction. The front-end page finds this method through this path. This method calls the data fetching method of the service layer and sends the returned List collection to the control layer. The control layer accepts the passed values ​​through the List and sends them back to the front-end through ModelAndView.
service layer code

List<Emp> show(PageBean page);

Mapper layer code:

<select id="selectByExample" parameterType="com.pojo.DeptExample" resultMap="BaseResultMap">
    select
    <if test="distinct">
      distinct
    </if>
    <include refid="Base_Column_List" />
    from dept
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
    <if test="orderByClause != null">
      order by ${orderByClause}
    </if>
    <if test="rows != null">
      <if test="offset != null">
        limit ${offset}, ${rows}
      </if>
      <if test="offset == null">
        limit ${rows}
      </if>
    </if>
  </select>

This is a whole piece of code for front-end and back-end interaction, which is equivalent to the "check" operation in the database. Other additions, deletions and modifications only need to modify part of the code. Due to the limitation of the content of the article, other codes will not be described in detail. , You can add WeChat to understand, I provide guidance and teaching for Java graduation design.

Guess you like

Origin blog.csdn.net/fzt12138/article/details/110817353