如何用java获取出来,并在jsp中显示
发布网友
发布时间:2022-05-25 09:33
我来回答
共3个回答
热心网友
时间:2023-10-03 13:06
java:
//String sql ="select * from g_supplier_sn where serial_number ="+getTextSN();
String sql="select pa.model_name,sn.serial_number,sn.supplier_sn,to_char(sn.update_time,'yyyy-mm-dd hh24:mi:ss') "+
"from sajet.g_supplier_sn sn inner join sajet.g_sn_status st on st.serial_number = sn.serial_number "+
"inner join sajet.sys_part pa on pa.part_id = st.model_id where sn.serial_number = ? ";
QuerySNDao db=new QuerySNDao();
ResultSet rs = null;
PreparedStatement stmt=null;
Connection con = db.getConnection();
result=new ArrayList<Map<String, String>>();
try{
stmt = con.prepareStatement(sql);
stmt.setString(1, textSN);
rs = stmt.executeQuery();
while (rs.next()) {
Map<String, String> lResult = new HashMap<String, String>();
String model_name = rs.getString(1);
String serial_number = rs.getString(2);
String supplier_sn = rs.getString(3);
String update_time = rs.getString(4);
lResult.put("modelName", model_name);
lResult.put("supplierSN", supplier_sn);
lResult.put("serialNumber", serial_number);
lResult.put("updateTime", update_time);
result.add(lResult);
}
}catch(SQLException e){
System.out.println(e.getMessage());
}finally{
db.closeConnection(con, rs, stmt);
}
return SUCCESS;
jsp:
<div class="contents">
<table width="85%" border="2px"
style="border-collapse: collapse;margin-left: 80px;">
<tr style="background-color:green;color: white;">
<th>机种名称</th>
<th>二维码</th>
<th>原材二维码</th>
<th>扫描时间</th>
</tr>
<s:iterator value="result" id="m">
<tr>
<td><s:property value="#m.modelName"/></td>
<td><s:property value="#m.serialNumber"/></td>
<td><s:property value="#m.supplierSN"/></td>
<td><s:property value="#m.updateTime"/></td>
</tr>
</s:iterator>
</table>
</div>
热心网友
时间:2023-10-03 13:06
java
XXaction.java
private List list;
//提供set/get方法
public String excute(){
list = HelperDao.queryForList("",null);
return "success";
}
jsp
<s:iterator value="list" var = "s">
<tr>${s.NAME}</td>
</s:iterator>
热心网友
时间:2023-10-03 13:06
使用el表达式啊