任何人都可以告诉我如何将java脚本变量的内容分配给scriptlet变量。 这是我的代码:
function getComment(location){
<%
try{
Class.forName(driver).newInstance();
con = DriverManager.getConnection(url+db,userName,password);
String locate=//i want here to assign the value of location;
String query = "select * from comments where location='"+locate+"'" ;
st = con.createStatement();
ResultSet rs = st.executeQuery(query);%>
<% int i=0;
while(rs.next()){%>
var comment = comment + "<BR>" + <%=rs.getString("comments")%>
<% i++; }
}
catch(Exception e){
e.printStackTrace();}
%>
return comment;
}