jQuery adding to JSP page

后端 未结 3 844
生来不讨喜
生来不讨喜 2021-01-02 12:48

I have a piece of jQuery code which I found on the internet and I want to integrate it to my jsp page, I use Spring form tags.

Here is the jQuery code:



        
3条回答
  •  说谎
    说谎 (楼主)
    2021-01-02 13:42

    if what you mean is that you want to bind Java side information to JS var, you can do as I did:

    1. At Java side, use Google's Gson to encode Java object to Json string.

    2. At Java side, use org.apache.commons.lang.StringEscapeUtils.escapeJavaScript(String) to make you Json string escaped as JavaScript.

    3. At JSP side, do something like this:

        
    

提交回复
热议问题