资源简介

传统的JAVAWEB项目,新闻管理功能(增删改查),用户管理功能(增删改查),发表评论功能(增删改查)。

资源截图

代码片段和文件信息

package controller;

import dao.DAOFactory;
import dao.IUserDao;
import model.User;
import model.UserException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * Created by Mr.Sad on 2017/9/7.
 */
@WebServlet(name = “UserServlet“ urlPatterns = {“/login.action““/reg.action“})
public class UserServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request HttpServletResponse response) throws ServletException IOException {


    }

    protected void doGet(HttpServletRequest request HttpServletResponse response) throws ServletException IOException {
        String url = request.getServletPath();
        if(url.equals(“/login.action“)){
            response.setContentType(“text/json; charset=utf-8“);
            PrintWriter out = response.getWriter();
            String username=request.getParameter(“username“);
            String password=request.getParameter(“password“);
            User u = new User();
            IUserDao iUserDao = DAOFactory.getUserDao();
            try{
            u =  iUserDao.Alogin(usernamepassword);
                if(u!=null){
                    out.print(“{\“login\“:true\“username\“:\““+username+“\“password\“:\““+password+“}“);
                }else{
                    out.print(“{\“login\“:false\“msg\“:\“用户名或密码错误\“}“);
                }
            }catch (UserException e){

            }

            out.flush();
        }else if(url.equals(“/reg.action“)){
            response.setContentType(“text/json; charset=utf-8“);
            PrintWriter out = response.getWriter();
            String username=request.getParameter(“username“);
            String password=request.getParameter(“password“);
            String nickname=request.getParameter(“nickname“);

            User user = new User();
            user.setUsername(username);
            user.setPassword(password);
            user.setNickname(nickname);
            user.setType(0);
            user.setStatus(0);
            IUserDao iUserDao = DAOFactory.getUserDao();
            try{
                iUserDao.add(user);
                if ((username == null||““.equals(username))&&(password == null||““.equals(password))&&(nickname == null||““.equals(nickname))){
                    out.print(“{\“reg\“:false\“msg\“:\“请输入注册信息\“}“);
                }else{
                    out.print(“{\“reg\“:true\“username\“:\““+username+“\“}“);
                }
            }catch (UserException e){

            }



            out.flush();
        }

    }
}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     文件         985  2017-12-28 02:00  NewsAAA\.classpath
     目录           0  2018-06-07 06:29  NewsAAA\.idea\
     目录           0  2018-05-09 11:58  NewsAAA\.idea\artifacts\
     文件        1342  2018-01-01 19:07  NewsAAA\.idea\artifacts\NewsAAA_war_exploded.xml
     文件         884  2017-12-18 16:32  NewsAAA\.idea\dataSources.local.xml
     文件         891  2017-08-27 15:05  NewsAAA\.idea\dataSources.xml
     目录           0  2018-05-09 11:58  NewsAAA\.idea\dataSources\
     文件        5738  2017-12-25 20:56  NewsAAA\.idea\dataSources\f463f71d-4bd0-4ce3-b771-ccf902209fd9.xml
     文件         238  2017-12-25 00:27  NewsAAA\.idea\encodings.xml
     目录           0  2018-05-09 11:58  NewsAAA\.idea\inspectionProfiles\
     文件         946  2017-10-04 17:55  NewsAAA\.idea\inspectionProfiles\Project_Default.xml
     目录           0  2018-05-09 11:58  NewsAAA\.idea\libraries\
     文件         775  2017-11-16 15:51  NewsAAA\.idea\libraries\Java_EE_6_Java_EE_6.xml
     文件         199  2017-12-11 10:20  NewsAAA\.idea\libraries\jstl_1_2.xml
     文件         231  2017-12-25 03:09  NewsAAA\.idea\libraries\jstl_impl.xml
     文件         224  2017-12-25 03:09  NewsAAA\.idea\libraries\jstl_standard.xml
     文件         224  2017-12-25 03:09  NewsAAA\.idea\libraries\mybatis_3_4_4.xml
     文件         261  2017-12-18 16:15  NewsAAA\.idea\libraries\mysql_connector_java_5_1_7_bin.xml
     文件         219  2017-12-18 16:15  NewsAAA\.idea\libraries\pager_src.xml
     文件         222  2017-12-25 03:09  NewsAAA\.idea\libraries\pager_taglib.xml
     文件         290  2017-12-28 02:00  NewsAAA\.idea\libraries\springmvc.xml
     文件         273  2017-08-25 22:14  NewsAAA\.idea\misc.xml
     文件         254  2017-08-22 13:46  NewsAAA\.idea\modules.xml
     文件         664  2017-12-27 18:21  NewsAAA\.idea\sqldialects.xml
     文件        8792  2017-09-11 21:38  NewsAAA\.idea\uiDesigner.xml
     文件         378  2017-08-27 15:42  NewsAAA\.idea\webContexts.xml
     文件      102659  2018-06-07 06:29  NewsAAA\.idea\workspace.xml
     文件         345  2017-12-25 18:03  NewsAAA\.project
     文件        1513  2017-12-26 17:54  NewsAAA\add.jsp
     目录           0  2018-05-09 11:58  NewsAAA\admin\
     文件         657  2017-12-09 06:47  NewsAAA\admin\delete.jsp
............此处省略379个文件信息

评论

共有 条评论