jsp中原:
<option value="${at['SID'] }" <c:if test="${syhhy ==at['SID']}">selected</c:if> >${fn:trim(at['SNAME']) }</option> -->  
需要修改成:
<%
   out.println(上面那段话);
%>   不知道out.println()中的话应该怎应改比较符合     

解决方案 »

  1.   

    <%
      out.println("<option value=\"${at['SID'] }\" <c:if test=\"${syhhy ==at['SID']}\">selected</c:if> >${fn:trim(at['SNAME']) }</option> --> ");
    %>
      

  2.   

    这样好像没用啊
    <select name="syhhy" id="syhhy">         
             <option value="">所有用户行业</option>
         <c:forEach var="at" items="${atlist}">            
             <% 
              out.println("<option value=\"${at['SID'] }\" <c:if test=\"${syhhy ==at['SID']}\">selected</c:if> >${fn:trim(at['SNAME']) }</option> ");
             %>                      
         </c:forEach>
    </select>
      

  3.   

    我这里的syhhy是这样取值到的
    <%
    String syhhy= (String)request.getAttribute("syhhy");
    %>如何放在out.println()中该如何调用呢
      

  4.   

    经测试:
    <% 
    out.println("<option value=\"${at['SID'] }\" <c:if test=\"${'01' ==at['SID']}\">selected</c:if> >${fn:trim(at['SNAME']) }</option> ");
    System.out.println("<option value=\"${at['SID'] }\" <c:if test=\"${'01' ==at['SID']}\">selected</c:if> >${fn:trim(at['SNAME']) }</option> ");          
    %>发现得出的结果是:
    <option value="${at['SID'] }" <c:if test="${'01' ==at['SID']}">selected</c:if> >${fn:trim(at['SNAME']) }</option> 可是用上面的在页面上得出的结果为:selected >${fn:trim(at['SNAME']) }我如果直接用<option value="${at['SID'] }" <c:if test="${'01' ==at['SID']}">selected</c:if> >${fn:trim(at['SNAME']) }</option> 
    得出的结果就是正常的数据"交通银行"这是为何呢?????
      

  5.   

    如果楼主清楚你那段代码做了什么,el表达式在其中起到了什么作用,就会做了。不过el表达式要简洁好看得多,不明白楼主为何要用jsp脚本
    附上代码供参考(未考虑null等异常情况):<% 
     String syhhy = (String)request.getAttribute("syhhy");
     //不知道你的at是什么类型,姑且当做map
     Map at = (Map)request.getAttribute("at");
     String sid = (String)at.get("SID");
     //要输出的html字符串 
     StringBuffer htmlStr = new StringBuffer("<option value=\"").append(sid)
     .append("\" ").append(syhhy.equals(sid) ? "selected" : "")
     .append(">").append(at.get("SNAME").toString().trim()).append("</option>");
    %>
      

  6.   


    最后加上一句 out.println(htmlStr.toString());