亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

JSP加載JS文件不起作用的有效解決方法

 更新時(shí)間:2014年04月08日 11:23:21   作者:  
jsp導(dǎo)入jquery文件,老是不起作用,原因在于其不能訪(fǎng)問(wèn)/WEB-INF/目錄下的文件,下面有個(gè)不錯(cuò)的解決方法,大家可以參考下
目錄結(jié)構(gòu):jsp導(dǎo)入jquery文件,老是不起作用,原因在于:
復(fù)制代碼 代碼如下:

<script type="text/javascript" src="js/jquery-1.4.2.min.js"></script>

其不能訪(fǎng)問(wèn)/WEB-INF/目錄下的文件,因此需要將加載的js文件其放倒webapp目錄。
 
test.html:
復(fù)制代碼 代碼如下:

<%@ page language="java" %>
<%@ page contentType="text/html; charset=UTF-8" %>
<%@ page import="java.util.*" %>
<%@ page isELIgnored="false" %>

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>

<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<html>
<head>
<base href="<%=basePath%>" />
<link rel=stylesheet type="text/css" href="css/style.css"/>
<script type="text/javascript" src="js/jquery-1.5.1.min.js"></script>

<script type="text/javascript">
$(document).ready(function() {
alert("hello, jquery");
});
</script>

<title>登錄</title>
</head>

<body>
<p class="error"><%=basePath%></p>
</body>
</html>

相關(guān)文章

最新評(píng)論