SSH开发web应用遇到的问题

凌风羽化 发布于 2014/03/11 18:15
阅读 205
收藏 1

Struts has detected an unhandled exception:

177: 178: 179: 180: 181: Stacktrace:

Messages:
  • An exception occurred processing JSP page /LoanInfo_query_result.jsp at line 178 175:
    <%=currentIndex %>
    176:
  • <%=loanInfo.getLoanId() %>
    <%=loanInfo.getBook().getBookName() %>
    <%=loanInfo.getReader().getReaderName() %>
    <%=loanInfo.getBorrowTIme() %>
    <%=loanInfo.getReturnTIme() %>
    File: org/apache/jsp/LoanInfo_005fquery_005fresult_jsp.java
    Line number: 299

    下面是相关代

    LoanInfo_query_result.jsp报错中提到的部分

    <tr>
                <td height="20" bgcolor="#FFFFFF"><div align="center" class="STYLE1">
                  <div align="center"><%=currentIndex %></div>
                </div></td>
                <td height="20" bgcolor="#FFFFFF"><div align="center"><span class="STYLE1"><%=loanInfo.getLoanId() %></span></div></td>
                <td bgcolor="#FFFFFF"><div align="center"><span class="STYLE1"><%=loanInfo.getBook().getBookName() %></span></div></td>
                <td bgcolor="#FFFFFF"><div align="center"><span class="STYLE1"><%=loanInfo.getReader().getReaderName() %></span></div></td>
                <td height="20" bgcolor="#FFFFFF"><div align="center"><span class="STYLE1"><%=loanInfo.getBorrowTIme() %></span></div></td>
                <td height="20" bgcolor="#FFFFFF"><div align="center"><span class="STYLE1"><%=loanInfo.getReturnTIme() %></span></div></td>
                <td height="20" bgcolor="#FFFFFF"><div align="center">
                <span class="STYLE4">
                <span style="cursor:hand;" onclick="location.href='<%=basePath %>LoanInfo/LoanInfo_ModifyLoanInfoQuery.action?loanId=<%=loanInfo.getLoanId() %>'"><a href='#'><img src="<%=basePath %>images/edt.gif" width="16" height="16"/>编辑&nbsp; &nbsp;</a></span>
                <img src="<%=basePath %>images/del.gif" width="16" height="16"/><a href="<%=basePath  %>LoanInfo/LoanInfo_DeleteLoanInfo.action?loanId=<%=loanInfo.getLoanId() %>" onclick="return confirm('确定删除本LoanInfo吗?');">删除</a></span>
                </div></td>
              </tr>



    LoanInfo.java

    package com.domain;
    
    public class LoanInfo {
        /*借阅编号*/
        private int loanId;
        public int getLoanId() {
            return loanId;
        }
        public void setLoanId(int loanId) {
            this.loanId = loanId;
        }
    
        /*图书对象*/
        private Book book;
        public Book getBook() {
            return book;
        }
        public void setBook(Book book) {
            this.book = book;
        }
    
        /*读者对象*/
        private Reader reader;
        public Reader getReader() {
            return reader;
        }
        public void setReader(Reader reader) {
            this.reader = reader;
        }
    
        /*借阅时间*/
        private String borrowTIme;
        public String getBorrowTIme() {
            return borrowTIme;
        }
        public void setBorrowTIme(String borrowTIme) {
            this.borrowTIme = borrowTIme;
        }
    
        /*归还时间*/
        private String returnTIme;
        public String getReturnTIme() {
            return returnTIme;
        }
        public void setReturnTIme(String returnTIme) {
            this.returnTIme = returnTIme;
        }
    
    }



    Book.java

    package com.domain;
    
    public class Book {
        /*图书名称*/
        private String bookName;
        public String getBookName() {
            return bookName;
        }
        public void setBookName(String bookName) {
            this.bookName = bookName;
        }
    
        /*图书所在类别*/
        private BookType bookType;
        public BookType getBookType() {
            return bookType;
        }
        public void setBookType(BookType bookType) {
            this.bookType = bookType;
        }
    
        /*图书价格*/
        private float price;
        public float getPrice() {
            return price;
        }
        public void setPrice(float price) {
            this.price = price;
        }
    
        /*库存*/
        private int count;
        public int getCount() {
            return count;
        }
        public void setCount(int count) {
            this.count = count;
        }
    
        /*出版社*/
        private String publish;
        public String getPublish() {
            return publish;
        }
        public void setPublish(String publish) {
            this.publish = publish;
        }
    
        /*图书条形码*/
        private String barcode;
        public String getBarcode() {
            return barcode;
        }
        public void setBarcode(String barcode) {
            this.barcode = barcode;
        }
    
    }




    加载中
    0
    zjxzjx
    zjxzjx
    都ssh了 为什么不用struts2标签输出
    凌风羽化
    凌风羽化
    回复 @zjxzjx : 配置文件在下面。
    凌风羽化
    凌风羽化
    回复 @zjxzjx : 我感觉没错啊,麻烦帮我看看,数据库的主键,外键都对。配置文件传到上面了。
    zjxzjx
    zjxzjx
    回复 @李香进 : 问题应该在你的hibernate映射文件 配置上面
    凌风羽化
    凌风羽化
    回复 @zjxzjx : 就是null,这个我知道。为什么取不到book对象和reader对象呢?我在另一处用reader.getReaderType( ).getTypeName( ) 是可以的。get和set方法都写了。
    zjxzjx
    zjxzjx
    回复 @李香进 : loanInfo.getBook()==null , loanInfo.getReader()​==null ,你在action里面打印一下看看
    下一页
    0
    凌风羽化
    凌风羽化
    <?xml version="1.0"?>
    <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
                                       "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
    <hibernate-mapping package="com.domain">
     <class name="LoanInfo" table="t_LoanInfo">
      <!-- 主键借阅编号 -->
      <id column="loanId" name="loanId">
       <generator class="native"/>
      </id>
      <!-- 多对一属性: 图书对象 -->
      <many-to-one cascade="save-update" class="Book" column="barcode"
       lazy="false" name="book" outer-join="true"/>
      <!-- 多对一属性: 读者对象 -->
      <many-to-one cascade="save-update" class="Reader" column="readerNo"
       lazy="false" name="reader" outer-join="true"/>
      <!-- 简单日期型属性: 借阅时间 -->
      <property column="borrowTIme" generated="never" lazy="false"
       length="10" name="borrowTIme" type="string"/>
      <!-- 简单日期型属性: 归还时间 -->
      <property column="returnTIme" generated="never" lazy="false"
       length="10" name="returnTIme" type="string"/> 
     </class>
    </hibernate-mapping>

    返回顶部
    顶部