struts2 jquery tag select not loading data

后端 未结 2 1650
陌清茗
陌清茗 2021-01-24 14:33

I am trying to use tag to render my list in Struts2 jsp.

At the same location I have used a tag as well

Data is getting populated

相关标签:
2条回答
  • 2021-01-24 15:04

    Solved.

    May this be of some help to others,

    All I had to do was change the web.xml as below:

     <filter-mapping>
        <filter-name>struts2</filter-name>
        <url-pattern>/*</url-pattern>
      </filter-mapping>
      <session-config>
    

    Earlier I had set the filter as

      <filter-mapping>
        <filter-name>struts2</filter-name>
        <url-pattern>*.action</url-pattern>
      </filter-mapping>
      <session-config>
    

    So the struts2-jquery tag could not find the corresponding .js files

    Solution: change from <url-pattern>*.action</url-pattern> to <url-pattern>/*</url-pattern> Thus, please be sure to check the web.xml for such anomalies which often go overlooked as in my case.

    0 讨论(0)
  • 2021-01-24 15:05

    You don't need to load jQuery twice, different versions might conflict with each other. This code is wrong

    <script src="<%=request.getContextPath()%>/jq/jquery-1.8.2.min.js"
        type="text/javascript"></script>
    
    <script src="<%=request.getContextPath()%>/jq/functions.js"
        type="text/javascript"></script>
    

    The sj:select tag should work if your action returns JSON, but it uses old notation. Change it to

    <s:url var="remoteurl" action="sample2"/> 
    <sj:select 
        href="%{#remoteurl}" 
        id="echo" 
        name="echo" 
        list="languageList" 
        emptyOption="true" 
        headerKey="-1" 
        headerValue="Please Select a Language"
    /> 
    

    Check that jquery, json plugins are on the class path and taglibs worked.

    0 讨论(0)
提交回复
热议问题