模仿了两个java,用意是通过传进来的一个Id值显示整条信息的详细。
ShowNewsById.javapackage com.air.ui; 
import java.sql.ResultSet;
import java.sql.SQLException;
import javax.naming.NamingException;
import com.air.util.DBconn;public class ShowNewsById{
public ShowNewsById(){}
public CheckNews ILoveYou(int Id)
throws SQLException, NamingException, ClassNotFoundException
{
String sql="select * from freenews where Id="+Id;
DBconn db=new DBconn();
ResultSet rs=db.executeQuery(sql);
rs.next();
CheckNews DoYouLoveMe=new CheckNews();
DoYouLoveMe.setAuthor(rs.getString("Author"));
DoYouLoveMe.setBigC(rs.getInt("BigC"));
DoYouLoveMe.setSmallC(rs.getInt("SmallC"));
DoYouLoveMe.setTitle(rs.getString("Title"));
DoYouLoveMe.setEditor(rs.getString("Editor"));
DoYouLoveMe.setContent(rs.getString("Content"));
DoYouLoveMe.setComment(rs.getString("Comment"));
DoYouLoveMe.setCount(rs.getInt("Count"));
DoYouLoveMe.setIsFree(rs.getInt("IsFree"));
DoYouLoveMe.setKeywords(rs.getString("Keywords"));
// DoYouLoveMe.setNewsDate(rs.getTime("NewsDate"));
rs.close();
db.close();
return Doq;
}
}
CheckNews.java
package com.air.ui; 
import com.air.util.AirDateTime;public class CheckNews{private int Id;
private String Title;
private String Content;
private String Author;
private String Editor;
private AirDateTime NewsDate;
private int Count;
private String Comment;
private String Keywords;
private int BigC;
private int SmallC;
private int IsFree;public CheckNews(){
}public void setId(int Id){
this.Id=Id;
}
public int getId(){
return Id;
}
public String getAuthor() {
return Author;
}
public void setAuthor(String author) {
Author = author;
}
public int getBigC() {
return BigC;
}
public void setBigC(int bigC) {
BigC = bigC;
}
public String getComment() {
return Comment;
}
public void setComment(String comment) {
Comment = comment;
}
public String getContent() {
return Content;
}
public void setContent(String content) {
Content = content;
}
public int getCount() {
return Count;
}
public void setCount(int count) {
Count = count;
}
public String getEditor() {
return Editor;
}
public void setEditor(String editor) {
Editor = editor;
}
public int getIsFree() {
return IsFree;
}
public void setIsFree(int isFree) {
IsFree = isFree;
}
public String getKeywords() {
return Keywords;
}
public void setKeywords(String keywords) {
Keywords = keywords;
}
public AirDateTime getNewsDate() {
return NewsDate;
}
public void setNewsDate(AirDateTime newsDate) {
NewsDate = newsDate;
}
public int getSmallC() {
return SmallC;
}
public void setSmallC(int smallC) {
SmallC = smallC;
}
public String getTitle() {
return Title;
}
public void setTitle(String title) {
Title = title;
}
}问题是在jsp页面调用的时候,在\<\%\%\>中用“out.print(DoYouLoveMe.getTitle());”可以在网页上打印出来,但是“\<\%=DoYouLoveMe.getTitle()\%\>”就会报错“An error occurred at line: 82 in the jsp file: /BackAdmin/shownews.jsp
Generated servlet error:
C:\eclipse\workspace\Air\work\org\apache\jsp\BackAdmin\shownews_jsp.java:138: cannot resolve symbol
symbol : variable DoYouLoveMe 
location: class org.apache.jsp.BackAdmin.shownews_jsp
out.print(DoYouLoveMe.getTitle());

DoYouLoveMe怎么会没定义呢?