本帖最后由 hughbeyond 于 2010-08-16 14:35:00 编辑

解决方案 »

  1.   

    把 request.getContextPath()打印出来,看看path的路径是否正确。
      

  2.   

    <script type="text/javascript" src="<%=path%>/struts/js/jquery-1.4.2.js"></script>
      

  3.   

    另外 response.jsfunction abc(){

    alert("");
    }
      

  4.   

       http://localhost:8080  可否?
       http://localhost:8080/TemplateWAR/默认页  可否 ?
        http://localhost:8080/TemplateWAR/struts/js/+重新写一个 js 文件,里面写简单内容看是否可以 
      

  5.   

      貌试 TemplateWAR 不是工程的名称吧 ?用相对路径试试  
       <script type="text/javascript" src="../struts/js/response.js"></script>
      

  6.   

    回复10楼http://localhost:8080/TemplateWAR/  能进入 welcomefile的login.jsp
    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>
      

  7.   

    另外我建的项目是用 eclipse建的 Web Fragment 项目
      

  8.   

    不过好像和项目没什么关系。我用Myelispe建的也不能用js资源。