JS文件引用不到(script 标签引用不到) 本帖最后由 hughbeyond 于 2010-08-16 14:35:00 编辑 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 把 request.getContextPath()打印出来,看看path的路径是否正确。 <script type="text/javascript" src="<%=path%>/struts/js/jquery-1.4.2.js"></script> 另外 response.jsfunction abc(){ alert("");} http://localhost:8080 可否? http://localhost:8080/TemplateWAR/默认页 可否 ? http://localhost:8080/TemplateWAR/struts/js/+重新写一个 js 文件,里面写简单内容看是否可以 貌试 TemplateWAR 不是工程的名称吧 ?用相对路径试试 <script type="text/javascript" src="../struts/js/response.js"></script> 回复10楼http://localhost:8080/TemplateWAR/ 能进入 welcomefile的login.jsphttp://localhost:8080/ 您输入的域名或网址无法访问!我的jsp<%@ page contentType="text/html; charset=UTF-8" language="java" %><%@ taglib prefix="s" uri="/struts-tags"%><%String path =request.getContextPath();%><html><head><script type="text/javascript" src="${pageContext.request.contextPath}/struts/js/response.js"></script><script type="text/javascript" src="../../../../struts/js/request.js"></script><script type="text/javascript">fuction showtips(str){ test(); abc();} /**function showtips(str){ abc(); if(str.length==0){ document.getElementById("tips").innerHTML=""; return; } xmlHttp = request(); if(xmlHttp==null){ return; } alert($("username")); var url="json/loginAjax.do"; var params ={username:document.getElementsByName("username").Value}; xmlHttp.open("POST",params,url,true); xmlHttp.onreadystatechange=response; xmlHttp.send(null); }function request() { var xmlHttp; try { // Firefox, Opera 8.0+, Safari xmlHttp = new XMLHttpRequest(); } catch (e) { // Internet Explorer try { xmlHttp = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) { alert("您的浏览器不支持AJAX!"); return false; } } } return xmlHttp;}function response(){ if (xmlHttp.readyState==4) { if (xmlHttp.status == 200) { alert(xmlHttp.responseText); } else { alert("您所请求的页面有异常。"); } alert(xmlHttp.responseText); var data = eval(xmlHttp.responseText); } } **/</script><style type="text/css">.errorMessage{color: red;font-size: 9;}</style></head> <body> <form name="login" action="login.do" method="post" > <table> <tr> <td>userName:</td><td><input name="username" type="text" onchange="showtips(this.value)"/></td> <td id="tips"><s:fielderror><s:param>username</s:param></s:fielderror></td> </tr> <tr> <td>password:</td><td><input name="password" type="password"/></td> </tr> <tr> <td><input type="submit" name="submit" value="submit"/></td> </tr> </table> </form> </body></html> 另外我建的项目是用 eclipse建的 Web Fragment 项目 不过好像和项目没什么关系。我用Myelispe建的也不能用js资源。 【急求】头像上传问题 如何获得JSP页面的超时时间? 为什么JavaScript无法执行? 远程空间的TOMCAT问题? dreamweaver里的可折叠面板粘贴到eclipse里需要改什么? 求教 关于浏览器 广告过滤的问题 “放入收藏夹”怎么实现 JSP乱码问题,请进! tomcat的classpath问题,急 急求bootstrap动态级联 用什么工具计算java程序的step数,请指教! java从jsp页面生成word
alert("");
}
http://localhost:8080/TemplateWAR/默认页 可否 ?
http://localhost:8080/TemplateWAR/struts/js/+重新写一个 js 文件,里面写简单内容看是否可以
<script type="text/javascript" src="../struts/js/response.js"></script>
http://localhost:8080/ 您输入的域名或网址无法访问!我的jsp
<%@ page contentType="text/html; charset=UTF-8" language="java" %>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%String path =request.getContextPath();
%><html>
<head>
<script type="text/javascript" src="${pageContext.request.contextPath}/struts/js/response.js"></script>
<script type="text/javascript" src="../../../../struts/js/request.js"></script>
<script type="text/javascript">fuction showtips(str){
test();
abc();
}
/**
function showtips(str){ abc();
if(str.length==0){
document.getElementById("tips").innerHTML="";
return; }
xmlHttp = request();
if(xmlHttp==null){
return;
}
alert($("username"));
var url="json/loginAjax.do"; var params ={username:document.getElementsByName("username").Value};
xmlHttp.open("POST",params,url,true); xmlHttp.onreadystatechange=response;
xmlHttp.send(null);
}
function request() {
var xmlHttp; try {
// Firefox, Opera 8.0+, Safari
xmlHttp = new XMLHttpRequest();
} catch (e) { // Internet Explorer
try {
xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) { try {
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {
alert("您的浏览器不支持AJAX!");
return false;
}
}
} return xmlHttp;}
function response(){
if (xmlHttp.readyState==4)
{
if (xmlHttp.status == 200) {
alert(xmlHttp.responseText);
} else {
alert("您所请求的页面有异常。");
}
alert(xmlHttp.responseText); var data = eval(xmlHttp.responseText);
}
} **/
</script><style type="text/css">
.errorMessage{color: red;
font-size: 9;
}
</style>
</head>
<body>
<form name="login" action="login.do" method="post" >
<table>
<tr>
<td>userName:</td><td><input name="username" type="text" onchange="showtips(this.value)"/></td>
<td id="tips"><s:fielderror><s:param>username</s:param></s:fielderror></td>
</tr>
<tr>
<td>password:</td><td><input name="password" type="password"/></td>
</tr>
<tr>
<td><input type="submit" name="submit" value="submit"/></td>
</tr>
</table>
</form>
</body></html>