MyErp-人事管理系统的问题总结

一、页面之间的传参问题

在jsp中,页面是可以通过param对象拿到路由参数的,而当我们采用传统的html方式,这种方法将不再适用。我们可以采取如下的方法来解决这个问题。
在这里插入图片描述
在这里插入图片描述

在该业务场景下,当我们点击修改后会跳到修改页面,而修改页面需要拿到部门的有关数据,在不使用jsp的情况下我们可以通过session来解决这个问题,当点击修改时,用ajax发送请求给后台,后台在session中设置一个属性来保存数据,随后浏览器发生页面跳转,当修改页面加载完成时发送ajax请求向后台拿session中存放的数据。
该方法的缺点很明显,非常繁琐并且加大的后台的负担,比较合适的解决方式是前台在修改时弹一个弹窗,在弹窗中修改页面而不发生页面跳转。

二、验证码问题

在这里插入图片描述
后端

 public void produceYZM(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // 在内存中创建图象
        int width = 110, height = 30;
        BufferedImage image = new BufferedImage(width, height,
                BufferedImage.TYPE_INT_RGB);
        // 获取图形上下文
        Graphics g = image.getGraphics();
        // 生成随机类
        Random random = new Random();
        // 设定背景色
        g.setColor(getRandColor(200, 250));
        g.fillRect(0, 0, width, height);
        // 设定字体
        g.setFont(new Font("Times New Roman", Font.PLAIN, 20));
        // 随机产生155条干扰线,使图象中的认证码不易被其它程序探测到
        g.setColor(getRandColor(160, 200));
        for (int i = 0; i < 155; i++) {
            int x = random.nextInt(width);
            int y = random.nextInt(height);
            int xl = random.nextInt(12);
            int yl = random.nextInt(12);
            g.drawLine(x, y, x + xl, y + yl);
        }
        // 取随机产生的认证码(6位数字)
        String sRand = "";
        for (int i = 0; i < 6; i++) {
            String rand = String.valueOf(random.nextInt(10));
            sRand += rand;
            // 将认证码显示到图象中
            g.setColor(new Color(20 + random.nextInt(110), 20 + random
                    .nextInt(110), 20 + random.nextInt(110)));
            // 调用函数出来的颜色相同,可能是因为种子太接近,所以只能直接生成
            g.drawString(rand, 13 * i + 6, 16);
        }
        // 图象生效
        g.dispose();
        //保存验证码到Session
        request.getSession().setAttribute("randStr", sRand);
        System.out.println(request.getSession().getAttribute("randStr"));
        try {
            ImageIO.write(image, "JPEG", response.getOutputStream());
        } catch (Exception e) {
            System.out.println("验证码图片产生出现错误:" + e.toString());
        }


    }
    public void checkYZM(HttpServletRequest req,HttpServletResponse resp) throws IOException {
        String code = req.getParameter("code");
        if(code.equals((String) req.getSession().getAttribute("randStr"))){
            resp.getWriter().print("flag=true");
        }else{
            resp.getWriter().print("flag=false");
        }
    }

前端

 $("#yzmImg").click(function () {
            console.log("切换验证码")
            $(this).attr("src","Login?method=produceYZM"+"&"+Math.random())
        })
        $("#yzm").blur(function(){
            console.log("失去焦点")
            $.ajax({
                    url:"Login?method=checkYZM",
                    method:"get",
                    data:{code:$(this).val()},
                    success:function(res){
                        $("#yzm-text").empty()
                        eval(res)
                        if(flag){
                            passYZM = true
                            $("#yzm-text").append("<small>验证码正确</small>")
                        }else{
                            passYZM = false
                            $("#yzm-text").append("<small>验证码错误</small>")
                        }
                    }

                })
            })
    
<span><input name="code" type="text" placeholder="验证码" id="yzm"/></span><cite><img src="Login?method=produceYZM" id="yzmImg" width="115px" height="46px"> </cite>

当页面加载完成时或者点击验证码图片时会发送请求切换验证码,验证码图形会发送到前端的img标签中

三、多表查询时出现多个同名字段,但表达的意义不同

<!--    多表查询、自查询 当表中出现同名字段(非连接字段)时需要起别名用来区分-->
    <select id="selectUpdate" resultMap="EmpMap2">
        select * from employee emp
        join dept on emp.deptno=dept.deptno
        join (select empid empid2,realname realname2 from employee) emp2 on emp.mgrid=emp2.empid2
        where emp.empid=#{param1}
    </select>
<resultMap id="EmpMap2" type="employee">
        <id column="empid" property="empid" ></id>
        <result column="password" property="password"></result>
        <result column="deptno" property="deptno"></result>
        <result column="posid" property="posid"></result>
        <result column="mgrid" property="mgrid"></result>
        <result column="realname" property="realname"></result>
        <result column="sex" property="sex"></result>
        <result column="birthdate" property="birthdate"></result>
        <result column="hiredate" property="hiredate"></result>
        <result column="leavedate" property="leavedate"></result>
        <result column="onduty" property="onduty"></result>
        <result column="emptype" property="emptype"></result>
        <result column="phone" property="phone"></result>
        <result column="qq" property="qq"></result>
        <result column="emercontactperson" property="emercontactperson"></result>
        <result column="idcard" property="idcard"></result>

        <association property="dept" javaType="Dept">
            <id column="deptno" property="deptno"></id>
            <result column="deptname" property="deptname"></result>
            <result column="location" property="location"></result>
        </association>
        <association property="mgr" javaType="employee">
            <id column="empid2" property="empid"></id>
            <result column="realname2" property="realname"></result>
        </association>

    </resultMap>

四、挂在webapp文件夹下的html文件访问不到的问题

需要在web.xml中添加如下配置

<servlet-mapping>
        <servlet-name>default</servlet-name>
        <url-pattern>*.css</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
        <servlet-name>default</servlet-name>
        <url-pattern>*.html</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
        <servlet-name>default</servlet-name>
        <url-pattern>*.js</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
        <servlet-name>default</servlet-name>
        <url-pattern>*.ico</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
        <servlet-name>default</servlet-name>
        <url-pattern>*.jpg</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
        <servlet-name>default</servlet-name>
        <url-pattern>*.png</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
        <servlet-name>default</servlet-name>
        <url-pattern>*.gif</url-pattern>
    </servlet-mapping>
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
免费个人博客系统(兼多用户博客系统)是支持一个空间2个网站的全能型网站管理系统,本免费个人博客系统通用和拓展性强,博客、文章系统、商城、企业网站、个性化论坛等类型网站都可以使用,将来网站无论如何转型或拓展,只需要修改模板就可以实现,无需重建网站。本系统不同于以往任何逻辑架构的网站程序。本软件开发者希望通过注重商业化开发,助力用户通过网络创业和赚钱,当然您也可以通过这个软件在互联网高效地展示自己。 详细说明: 1.本个人博客系统可以用于商业用途,本软件官方、开发者不收取任何授权费用; 2.本个人博客系统是支持一个空间2个网站的全能型博客系统; 3.本个人博客系统通用和拓展性强,博客、文章系统、商城、企业网站、个性化论坛等类型网站都可以使用; 4.本个人博客系统功能强大,代码少,运行效率更高,程序运行速度是其它主流同类软件的3~4倍,内存占用不到其它主流同类软件的五分之一; 5.开启和关闭会员注册,开启和关闭普通会员投稿功能; 6.会员功能拓展到了兼职专题功能,SEO设置和开放特约编辑的多用户不同权限管理功能等; 7.超级管理员可无密码一键登录任意会员后台,管理员用受限登录会员身份后台发布信息,也可让网站攻击者无法猜解密码; 8.自动生成手机版网站,系统默认带www的域名为PC模板站,不带www的顶级域名为手机站,不增加维护难度,就可以同时拥有2个网站; 9.博客程序还包含订单、秒杀、限时抢购和数量虚拟功能,助力用户互联网创业和商业化运营,就看脑洞大开的你怎么使用了; 10.本个人博客系统能够适应各种界面浏览器,后台可手机随时随地访问、管理和更新网站; 11.可一键切换成.shtml、.html、.htm、.asp、.aspx、.cgi、.php、.jsp、.cgi、/ 等网页后缀,模拟不同语言编程的网站程序; 12.前端页面精简,前端编码不用div标签,不用id、class规则的CSS样式,最大限度精简前端代码,鼓励用户抛弃div+CSS前端代码编写模式,我们这样做不是为了迎合HTML5,只是为了更合理的应用HTML标签; 13.安装程序自动识别和设置伪静态; 14.全站无死角SEO设置; 15.强大的内链逻辑,特别适应大数据类型网站使用; 16.强大的广告和精准广告设置; 17.数据缓存模式,不依赖外部服务器组件和其它插件,不额外占用服务器系统内存资源; 18.删除局部缓存和一键清除全部缓存; 19.可设置邮件实时通知新订单和访客留言; 20.可设置管理员回复留言可同时邮件通知留言者; 21.可查看和删除无用上传文件,为将来数据备份节省时间和空间; 22.特色的tag标签功能; 23.分类、tag标签、url表单填写自动补缺; 24.url表单可自动生成拼音,也可以用汉字,自动转码,有利于SEO搜索引擎排名; 25.开放式PHP原生态模板,用户任意修改、穿插内容或广告,无需花时间研究额外规则,模板修改成本更低; 26.可对模板备份,使用备份模板,并可对模板恢复系统初始状态; 27.模板修改全站页面秒更新; 28.可自定义SQL语句的图片展示页面; 29.后台可控制各个模块是否开启验证码、设置验证码长度,以及设置验证码破解难度; 30.访客留言关键词过滤; 31.可自定义导航; 32.可在线编辑js和CSS文件; 33.本免费个人博客系统(兼多用户博客系统)无后门。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值