楼主使用strut+hibernate比较有特色。呵呵。
我提供我以前写JavaMail的一段代码供参考。
</TR>
<logic:iterate id="mesg" name="al_mesg" scope="session"〉
<TR>
<logic:iterate id="list" name="mesg">
<TD><bean:write name="list" filter="false"/></TD>
</logic:iterate>
</TR>
</logic:iterate>
我提供我以前写JavaMail的一段代码供参考。
</TR>
<logic:iterate id="mesg" name="al_mesg" scope="session"〉
<TR>
<logic:iterate id="list" name="mesg">
<TD><bean:write name="list" filter="false"/></TD>
</logic:iterate>
</TR>
</logic:iterate>
ArrayList arraylist=new ArrayList();
String[] mesg=new String[5];
mesg[1]=pmm.getFrom();
mesg[2]=pmm.getSentDate();
.........
arraylist.add(mesg);
ArrayList al_mesg=r.getAllMessage();
session.setAttribute("al_mesg",al_mesg);
+ "from com.test.user as a,com.test.other as b"
+ " where a.userid=b.userid"
改未:
写这样一个类:
public class TUser {
private String userId;
private String userName;
private String country;
public String getCountry() {
return country;
}
public TUser(String userId, String userName, String country) {
super();
// TODO Auto-generated constructor stub
this.userId = userId;
this.userName = userName;
this.country = country;
} public void setCountry(String country) {
this.country = country;
}
public String getUserId() {
return userId;
}
public void setUserId(String userId) {
this.userId = userId;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}然后
将改String query = "select new TUser(a.userid,a.username,b.contry)"
+ "from com.test.user as a,com.test.other as b"
+ " where a.userid=b.userid"
最后将该对象放入ArrayList中,就OK了
<logic:iterate id="student" name="list" type="eqzhou.mis.student.Student">
<!--nested:nest property="student"-->
<tr>
<td height="25" bgcolor="#F3F3F3" class="menu_list"><div align="center"><%=ConversionCharacter.conversion(((Student)student).getStudentId())%></div></td>
<td height="25" bgcolor="#F3F3F3" class="menu_list"><div align="center"><%=ConversionCharacter.conversion(((Student)student).getName())%></div></td>
<td height="25" bgcolor="#F3F3F3" class="menu_list"><div align="center"><%=ConversionCharacter.conversion(((Student)student).getSex())%></div></td>
<td height="25" bgcolor="#F3F3F3" class="menu_list"><div align="center"><%=((Student)student).getEnrollmentDate()%></div></td>
<td height="25" bgcolor="#F3F3F3" class="menu_list">
<div align="center">
<%=ConversionCharacter.conversion(((Student)student).getCollege().getCollegeId())%>
</div>
</td>
<td height="25" bgcolor="#F3F3F3" class="menu_list"><div align="center">
<!--======特别注意,在这里主键的名字必须为 key ,因为在后台是根据 key 来查找的=====-->
<a href="/studentAction.do?actionType=3&key=<%=ConversionCharacter.conversion(((Student)student).getStudentId())%>">
<img src="../../../images/iedit.gif" alt="修改" width="16" height="16" border="0">
</a>
<img src="../../../images/idelete.gif" alt="删除" width="16" height="16" border="0"> </div>
</td>
</tr>
<!--/nested:nest-->
</logic:iterate>
</logic:present>
public user(String id,String name,String country){
this.userid=id;
this.username=name;
this.country=country;
}
把HQL改成下面的方式
String query = "select new com.test.user(a.userid,a.username,b.contry) from com.test.user as a,com.test.other as b where a.userid=b.userid"
这样查询出来的结果就可以用你原来的方法显示出来你原来的查询语句查询出来的是一个数组,可以用JSTL的<c:out>显示出来