jsp里面不能使用${pageContext.request.contextPath}解决方案
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>
jsp里面不能使用${pageContext.request.contextPath}解决方案的更多相关文章
- jsp获取绝对路径----${pageContext.request.contextPath}
JSP取得绝对路径 在JavaWeb开发中,常使用绝对路径的方式来引入JavaScript和CSS文件,这样可以避免因为目录变动导致引入文件找不到的情况,常用的做法如下: 一.使用${pageCont ...
- ${pageContext.request.contextPath} JSP取得绝对路径
一.问题 JSP中究竟采用绝对路径还是采用相对路径随着所采用技术的越来越复杂,这个问题也变得越来越难以解决. 1)采用相对路径遇到的问题 相对路径固然比较灵活,但如果想复制页面内的代 ...
- ${pageContext.request.contextPath}是JSP取得绝对路径(转载)
${pageContext.request.contextPath}是JSP取得绝对路径的方法,等价于<%=request.getContextPath()%> . 也就是取出部署的应用程 ...
- jsp中${pageContext.request.contextPath}的意思
${pageContext.request.contextPath}是JSP取得绝对路径的方法,等价于<%=request.getContextPath()%> . 也就是取出部署的应用程 ...
- <jsp:include page="${pageContext.request.contextPath/index.jsp" ></jsp:include> 引发的错误
路径引发的错误 如下使用项目路径对jsp页面进行获取,会报javax.servlet.ServletException: File "/web/dbwx/web/public/page_to ...
- 关于在JSP页面中为什么一定要用${pageContext.request.contextPath}来获取项目路径,而不能用${request.contextPath}?
这里的疑问在于pageContext和request都是JSP中的内置对象之一,为什么不直接用${request.contextPath}来获取项目路径? 出现这种疑问,其实是将JSP的内置对象和EL ...
- 【JSP】${pageContext.request.contextPath}
取出部署的应用程序名或者是当前的项目名称 http://localhost:8080/demo1/a.jsp ${pageContext.request.contextPath}或<%=req ...
- JSP之项目路径问题(${pageContext.request.contextPath},<%=request.getContextPath()%>以及绝对路径获取)
本随笔这是作为一个记录使用,以备后查.项目完成之后本地部署OK,本地Linux部署OK,都可以正常的访问,可是当我把它部署到服务器上面的时候,首页可以正常访问,可是当发出请求的时候却报错误了,说找不到 ...
- 关于${pageContext.request.contextPath}的理解 (转载)
${pageContext.request.contextPath}是JSP取得绝对路径的方法,等价于<%=request.getContextPath()%> . 也就是取出部署的应用程 ...
随机推荐
- TZOJ 3710 修路问题(最小差值生成树kruskal或者LCT)
描述 xxx国“山头乡”有n个村子,政府准备修建乡村公路,由于地形复杂,有些乡村之间可能无法修筑公路,因此政府经过仔细的考察,终于得到了所有可能的修路费用数据.并将其公布于众,广泛征求村民的修路意见. ...
- 【网络编程三】网络通信之多进程(线程)实现TCP通信(一)
[多进程] [多线程] /************************************************************************* > File sum ...
- linux操作Mysql数据库基本命令
1.显示数据库 show databases; 2.选择数据库 use 数据库名; 3.显示数据库中的表 show tables; 4.显示数据表的结构 describe 表名; 5.显示表中记录 S ...
- Bootstrap(8) 路径分页标签和徽章组件
一.路径组件路径组件也叫做面包屑导航.//面包屑导航 <ol class="breadcrumb"> <li><a href="#" ...
- svn-经常遇到问题解答办法积累(一)
1.对于一个SVN使用新手,第一步,肯定是如何获取代码到本地指定的目录. 步骤: (1)新建一个存放svn中某一个代码库的目录,加入该目录命名为:Proj1SVN (2)右键鼠标,选择SVN Chec ...
- c++中“箭头(->)”和“点号(.)”操作符的区别
首先介绍一下C++中的结构.对于一个结构: struct MyStruct { int member_a; }; 如果有个变量MyStruct s,那么使用其中的成员元素时可以用: s.member_ ...
- Java使用默认浏览器打开指定URL的方法(二种方法)
直接看代码:方法一: 复制代码 代码如下: Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler http://ww ...
- java基础之—类加载器
要了解类加载器先要了解类的加载 一.类的加载(类的加载概述) 当程序要使用某个类时,如果该类还未被加载到内存中,则系统会通过加载,连接,初始化三步来实现对这个类进行初始化. 1.加载 就是指将clas ...
- 差异表达分析之FDR
差异表达分析之FDR 随着测序成本的不断降低,转录组测序分析已逐渐成为一种很常用的分析手段.但对于转录组分析当中的一些概念,很多人还不是很清楚.今天,小编就来谈谈在转录组分析中,经常会遇到的一个概念F ...
- 全基因组测序 Whole Genome Sequencing
全基因组测序 Whole Genome Sequencing 全基因组测序(Whole Genome Sequencing,WGS)是利用高通量测序平台对一种生物的基因组中的全部基因进行测序,测定其 ...