2014-04-19 27 views
0

我有一個web應用程序,使用spring mvc。主頁顯示正確(jquery滑塊顯示正確)。當我嘗試去另一個頁面時,url路徑被識別爲正確,頁面按預期方式顯示,但沒有jquery(滑塊內容顯示爲jquery未被識別)。重定向後,彈簧MVC jQuery不工作?

控制器方法:

@RequestMapping(value = "/menu", method = RequestMethod.GET) 
public String listMenu(Model model) { 
    ... 
    return "menu"; 
} 

@RequestMapping(value = "menu/category/{cName}", method = RequestMethod.GET) 
public String listCategory(@PathVariable("cName")String category, Model model) { 
       .... 
    return "menu/category"; 
} 

我用磚

<tiles-definitions> 
    <definition extends="default" name="menu"> 
     <put-attribute name="body" value="/WEB-INF/views/menu/menu.jspx" /> 
    </definition> 
    <definition extends="default" name="menu/category"> 
     <put-attribute name="body" value="/WEB-INF/views/menu/category.jspx" /> 
    </definition> 
</tiles-definitions> 

當我去... /菜單網址jQuery的滑塊仍然顯示精細,當...菜單/類別/名稱即使menu.jspx和category.jspx具有相同的內容,也會出現上述問題。請幫幫我!

到CSS的鏈接和腳本在這是該網站的佈局default.jspx,

<script type="text/javascript" src="resources/banner/js/jquery.cslider.js"><jsp:text/></script> 

我試着用<春:網址>以及

+0

什麼是在您的網頁jQuery源代碼的鏈接? –

+0

指向css和腳本的鏈接是default.jspx,它是站點的佈局,

+0

請編輯你的問題並在那裏添加那個細節。另外,你是否有適當的資源處理程序? –

回答

0

的問題可能有請使用您正在使用的視圖的路徑和JavaScript資源的路徑。對JavaScript文件的路徑需要或者是絕對在這種情況下,他們還是執意要在這兩個視圖文件相同,或相對在這種情況下,他們不會同

0

嘗試添加像下面的靜態資源配置:

<mvc:resources order="12" location="/css/" mapping="/css/**"/> 
<mvc:resources order="13" location="/js/" mapping="/js/**"/> 
<mvc:resources order="14" location="/images/" mapping="/images/**"/>