【发布时间】:2017-11-27 06:31:56
【问题描述】:
我有一个显示客户信息的jsp
<s:textfield key="customer.firstname" required="true" readonly="true"/>
<s:textfield key="customer.lastname" required="true" readonly="true"/>
<s:textfield key="customer.loginid" required="true" readonly="true"/>
<s:textfield key="customer.telephone" required="true" readonly="true"/>
我试过了
<c:set var = "customer_loginid" scope = "session" value = "${customer.loginid}"/>
<c:out value = "${customer_loginid}"/>
可以按变量显示值。
然后我想用它从数据库中获取数据。
<%
connection = DriverManager.getConnection(connectionUrl+dbName, userId,
password);
statement=connection.createStatement();
//String customerLoginid = ${customer_loginid};//It does not allow me to put the variable here
//also tried
//String customerLoginid = {String) ${customer_loginid};//It does not allow me to put the variable here
String customerLoginid = x; //how to put the variable here??
String sql = "select ordered_product from table2 where customerid ='"+customerLoginid+"'"
ResultSet resultSet = statement.executeQuery(sql)
while(resultSet.next())
{
resultSet.getString("ordered_product")
}
resultSet.close();
statement.close();
%>
那么如何将${customer_loginid}放在jsp的sql查询中呢?感谢您的建议。谢谢。
【问题讨论】: