jsp:useBean如何取集合中的数据来自动填充???
struts-config:
<form-bean name= "UserForm " type= "com.ydx.struts.UserForm ">
...
<action path= "/query " scope= "request "
type= "com.ydx.struts.UserAction " name= "UserForm ">
<forward name= "list " path= "/jsp/Show.jsp " />
<action path= "/Showj " forward= "/jsp/Showj.jsp "> </action>
...
Action:
public ActionForward list(ActionMapping mapping,
ActionForm form,HttpServletRequest request,
HttpServletResponse response)throws Exception {
Dao dao = new Dao();
List ls = dao.get( "from User ");
request.setAttribute( "list ", ls);
return mapping.findForward(( "list ");
}
...
package com.ydx.hibernate;
public class User {
private String id;
private String name;
public void setId(String id){
this.id=id;
}
public String getId(){
return this.id;
}
public void setName(String name){
this.name=name;
}
public String getName(){
return this.name;
}
}
...
Show.jsp
<logic:iterate id= "dto " name= "list ">
<tr>
<td> <bean:write name= "dto " property= "id "/> </td>
<td> <bean:write name= "dto " property= "name "/> </td>
<td> <html:link action= "/Showj.do " paramName= "dto " paramId= "id " paramProperty= "id "> 显示 </html:link> </td>
</tr>
</logic:iterate>
...
Showj.jsp
我想在Show.jsp中点某条记录的 "显示 "链接后,跳转到Showj.jsp来显示相应数据.
这个Showj.jsp怎么写才能通过一个传过来的id 用 <jsp:useBean > <jsp:getProperty > 来显示数据????
------解决方案--------------------估计得根据id做一次查询然后才能显示
帮你顶~~