随笔 - 475,  文章 - 0,  评论 - 66,  阅读 - 396万

1.在jsp中使用${pageContext.request.contextPath}获取相对路径,可是最后路径变为:http://localhost:8080/oneself/$%7BpageContext.request.contextPath%7D/css/reset.css
2.贴图,这是浏览器的调试页面,可以看到获取css的路径带上了${pageContext.request.contextPath},而console中打印的获取css地址为$%7BpageContext.request.contextPath%7D,并不清楚什么原因,希望各位大佬指点。
图片描述

login.jsp页面

 
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Login</title>
<!-- CSS -->
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/reset.css">
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/supersized.css">
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/style.css">
    <!-- Javascript -->
    <script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery.min.js" ></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/js/supersized.3.2.7.min.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/js/supersized-init.js"></script>
<!-- HTML5 shim, for IE6-8 support of HTML5 elements -->
<!--[if lt IE 9]>
            <!--<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>-->
        <!--[endif]-->
</head>

<body oncontextmenu="return false">
    <div class="page-container">
        <div id="log-box">
            <h1>登 录</h1>
            <form action="${pageContext.request.contextPath}/user/login.do" method="post">
                <table>
                    <tr>
                        <td class="log-reg">
                            <div>
                                <input type="text" id="username" name="username" class="username"
                                    placeholder="用户名/邮箱名" autocomplete="off" onblur="validname()" />
                            </div></td>
                        <td class="errmsg"><span style="overflow: hidden;"
                            id="errorMsgname" />
                        </td>
                    </tr>
                    <tr>
                        <td class="log-reg">
                            <div>
                                <input id="password" type="password" name="password" class="password"
                                    placeholder="密码" oncontextmenu="return false"
                                    onpaste="return false" onblur="validpwd()" />
                            </div>
                        <td class="errmsg"><span style="overflow: hidden;" id="errorMsgpwd" />
                        </td>
                    </tr>
                    <tr>
                        <td colspan="2" class="btn-left"><input type="submit"
                            class="btn" id="submit" value="登  录" />
                        </td>
                    </tr>
                    <tr>
                        <td colspan="2" class="btm-left">
                            <p class="box-button">
                                没有账号,先 <a href="${pageContext.request.contextPath}/user/showregister.do">注册</a>
                            </p>
                        </td>
                    </tr>
                    <tr>
                        <td colspan="2" class="btm-pa">
                            <p class="box-button" id="btm-p">
                                <a href="#">忘记密码?</a>
                            </p>
                        </td>
                    </tr>
                </table>
            </form>
        </div>
        <div class="connect">
            <p>If we can only encounter each other rather than stay with each
                other,then I wish we had never encountered.</p>
            <p style="margin-top:20px;">如果只是遇见,不能停留,不如不遇见。</p>
        </div>
    </div>
    <div class="alert" style="display:none">
        <h2>消息</h2>
        <div class="alert_con">
            <p id="ts"></p>
            <p style="line-height:70px">
                <a class="btn">确定</a>
            </p>
        </div>
    </div>

    <script type="text/javascript">
            $(".btn").click(function() {
                is_hide();
            });
            $("#submit").live('click', function() {
                var u = $("#username");
                var p = $("#password");
                if (u.val() == '' || p.val() == '') {
                    $("#ts").html("用户名或密码不能为空~");
                    is_show();
                    return false;
                } else {
                    var reg = /^[0-9A-Za-z]+$/;
                    if (!reg.exec(u.val())) {
                        $("#ts").html("用户名错误");
                        is_show();
                        return false;
                    }
                }
            });
            window.onload = function() {
                $(".connect p").eq(0).animate({
                    "left" : "0%"
                }, 600);
                $(".connect p").eq(1).animate({
                    "left" : "0%"
                }, 400);
            };

            function is_hide() {
                $(".alert").animate({
                    "top" : "-40%"
                }, 300);
            }

            function is_show() {
                $(".alert").show().animate({
                    "top" : "45%"
                }, 300);
            };
            function validname() {
                var val = $("#username").val();
                if (val == '' || $.trim(val) == '') {
                    $("#errorMsgname").html('用户名不能为空');
                    $("#errorMsgname").show();
                } else  {
                    $.ajax({
                        type: "post",
                        url: "finduserisnull.do?info=" + val,
                        data: "",
                        success: function(data) {
                            if(data=="false"){
                                $("#errorMsgemail").html('用户未注册!');
                            }else {
                                $("#errorMsgemail").html('<img src="img/yes.jpg" style="width: 18px;height: 18px;"/>');
                            }}
                        });
                    }
            };
            function validpwd() {
                //获取id为password对应的input输入框中的值
                var val = $("#password").val();
                if (val == '' || $.trim(val) == '') {
                    //如果val为空或者空格,将错误消息显示在对应span
                    $("#errorMsgpwd").html('密码不能为空');
                    //让span显示出来
                    $("#errorMsgpwd").show();
                } else {
                    $("#errorMsgpwd").html('<img src="${pageContext.request.contextPath}/img/yes.jpg" style="width: 18px;height: 18px;"/>');
                }
            };
    </script>
</body>

</html>
posted on   锋齐叶落  阅读(5255)  评论(3编辑  收藏  举报
编辑推荐:
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
阅读排行:
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· C#/.NET/.NET Core优秀项目和框架2025年2月简报
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· 【杭电多校比赛记录】2025“钉耙编程”中国大学生算法设计春季联赛(1)
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

点击右上角即可分享
微信分享提示