----【页面显示的就是这样。。也没有提示错误。 就是丢失数据】
  
 名称:七匹狼秋季长袖时尚衬衫 
价格: 
单位:件 
折扣: 
简介: 
 
  -------【这是jsp页面】------ <s:iterator value="#request.productAttr" var="temp">
    <td><table width="30%" border="0">
      <tr>
        <td colspan="2">&nbsp;</td>
      </tr>
      <tr>
        <td rowspan="4"><img src="/img2/<s:property value="#temp.pPhoto"/>"></td>
        <td>名称:<s:property value="#temp.proName"/></td>
      </tr>
      <tr>
        <td>价格:<s:property value="#temp.pPrice"/></td>
      </tr>
      <tr>
        <td>单位:<s:property value="#temp.proUnit"/></td>
      </tr>
      <tr>
        <td>折扣:<s:property value="#temp.pCount"/></td>
      </tr>
      <tr>
        <td colspan="2">简介:<s:property value="#temp.pIntroduce"/></td>
      </tr>
    </table></td>
    </s:iterator>------【这是action】------public String showProduct(){

ProductDao dao=new ProductDao();
ArrayList<Product> al=dao.showProduct();
request.put("productAttr", al);
return "ok";

}
--------【这是业务逻辑】----public ArrayList<Product> showProduct(){
ArrayList<Product> al=new ArrayList<Product>();
String sql="select * from product_table";
JDBCTool dbhelper = JDBCToolCreator.createJDBCTool();
ResultSet rs=dbhelper.search(sql);
try {
while(rs.next()){
Product pt=new Product();
pt.setProId(rs.getString(1));
pt.setPc1Id(rs.getString(2));
pt.setPc2Id(rs.getString(3));
    pt.setProName(rs.getString(4));
pt.setProUnit(rs.getString(5));
pt.setpPrice(rs.getString(6));
pt.setpCount(rs.getString(7));
pt.setpVender(rs.getString(8));
pt.setpIntroduce(rs.getString(9));
pt.setpDate(rs.getString(10));
pt.setpPhoto(rs.getString(11));

al.add(pt);
}
---------------这是实体类(get,set没粘贴。。都有)-----
private String proId;//商品号
private String pc1Id;//1类编号
private String pc2Id;//2类编号
private String proName;//商品名称
private String proUnit;//计量单位
private String pPrice;//单价
private String pCount;//折扣
private String pVender;//生产商
private String pIntroduce;//简介
private String pDate;//上线时间
private String pPhoto;//图片

解决方案 »

  1.   

     <tr>         <td>价格:<s:property value="#temp.pPrice"/></td>       </tr>       <tr>         <td>单位:<s:property value="#temp.proUnit"/></td>       </tr>       <tr>         <td>折扣:<s:property value="#temp.pCount"/></td>       </tr>       <tr>         <td colspan="2">简介:<s:property value="#temp.pIntroduce"/></td> 
    名称大小写错了,有些记不清了,如果bean第二个字母大写的话,jsp中第一个字母应该是大写,你试试,如果不行的话,把bean中的字段都写成pro*,然后jsp中可以写原名
      

  2.   

    好像是这样的,改成这样试试
     <s:iterator value="#request.productAttr" var="temp">
        <td><table width="30%" border="0">
          <tr>
            <td colspan="2"> </td>
          </tr>
          <tr>
            <td rowspan="4"><img src="/img2/<s:property value="#temp.PPhoto"/>"></td>
            <td>名称:<s:property value="#temp.proName"/></td>
          </tr>
          <tr>
            <td>价格:<s:property value="#temp.PPrice"/></td>
          </tr>
          <tr>
            <td>单位:<s:property value="#temp.proUnit"/></td>
          </tr>
          <tr>
            <td>折扣:<s:property value="#temp.PCount"/></td>
          </tr>
          <tr>
            <td colspan="2">简介:<s:property value="#temp.PIntroduce"/></td>
          </tr>
        </table></td>
        </s:iterator>
      

  3.   

     pt.setpPrice(rs.getString(6));
                    pt.setpCount(rs.getString(7));
                    pt.setpVender(rs.getString(8));
                    pt.setpIntroduce(rs.getString(9));
                    pt.setpDate(rs.getString(10));
                    pt.setpPhoto(rs.getString(11));
    难道是这几个字段没有值?如果第二个字母大写的话,用eclipse生成get,set方法(看结果你是这样做的),set后面的第一个字母会是小写的。但是struts2拦截器会调用后台类中的setPIntroduce方法,但是你的是setpIntroduce,所以没有set进去值,也就没值了。set后的首字母都大写就没事了。
      

  4.   

    估计是bean建的不够规则
    private String proName;//商品名称
    private String proUnit;//计量单位
    private String pPrice;//单价
    商品名称和单位可以出来,但是价格确丢失了
    建议将类似pPrice;//单价属性修改下,如proPrice或者干脆price,然后试试
      

  5.   

    Quote: 引用 2 楼 yyw6637 的回复:

    把bean中的字段都写成pro*,然后jsp中可以写原名 
    嗯嗯改成pro*以后好使了。。谢谢。