測試頁面代碼:
<script type="text/javascript" src="js/jquery-1.7.2.min.js"></script>
<title>首頁</title>
<script type="text/javascript">
$().ready(function(){
alert("test");
});
</script>
</head>
導入的路徑沒問題,也沒有js先后順序干擾,但提示ReferenceError: $ is not defined,導入jquery失敗,沒有定義。新建一個簡單的工程一樣的js訪問路徑,一樣的測試頁面卻可以,說明js文件也沒問題。
原來spring需要在配置文件里配置才能訪問靜態文件:添加<mvc:resources location="/js/" mapping="/js/**"/> 問題解決。
