jsp页面中javascript访问 java的变量

<%= JAVA变量名%>

jsp中嵌入java代码
<%java代码%>
--变量
<% String JAVASOut="javaString";%>
var
JSout = '<%=JAVAout%>';

--取字段
<%
  ResultSet rs = null;
  TQuery aq = new TQuery();
  rs = aq.getAll();
 %>
<table border="1" cellpadding="0" cellspacing="0">
<%while (rs.next()) {%>
   <tr>
    <td><%=rs.getString("姓名") %></td>
    <td><%=rs.getString("性别") %></td>
    <td><%=rs.getString("年龄") %></td>
   </tr>
   <%System.out.println();
   } %>
</table>

 

<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

posted on 2015-01-13 16:18  lypzxy  阅读(347)  评论(0编辑  收藏  举报