struct problem, why do you always find bean it?

Category: Web Develop
 
iyylanbing
2012-02-18 07:06:58

Sponsored Links
How old errors: please help heroes!
javax.servlet.ServletException: Cannot find bean clings in scope null

1, shows the following code:
<logic: iterate id = "cling" name = "clings" type = "manager.model.Cling">
<tr>
; <td bgcolor="#FFFFFF"> <bean:write name="cling" property="id" scope="request"/> </td>
<td bgcolor="#FFFFFF"> <bean: write name = "cling" property = "code" scope = "request" /> </td>
<td bgcolor="#FFFFFF"> <bean: write name = "cling" property = "name" scope = "request" /> </td>
<td bgcolor="#FFFFFF"> < ; bean: write name = "cling" property = "author" scope = "request" /> </td>
</tr>
</ logic: iterate>

2, Action reads as follows:
public class ClingAction extends Action {
public ActionForward perform (ActionMapping actionMapping, ActionForm actionForm, HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) {
DataSource ds = (DataSource) servlet . getServletContext (). getAttribute (Action.DATA_SOURCE_KEY);
ClingDAO clingDAO = new ClingDAO (ds);
try {
List clings = clingDAO.list ();
}
catch (SQLException e) {
return actionMapping.findForward ("failure");
;}
return actionMapping.findForward ("success");
}
}
3, ClingDAO follows :
public List list () throws SQLException {
ArrayList list = new ArrayList ();
; Connection conn = null;
PreparedStatement pstmt = null;
ResultSet rs ; = null;
try {
conn = ds.getConnection ();
String sql = "select * from cling";
pstmt = conn.prepareStatement (sql);
rs = pstmt.executeQuery ();
; while (rs.next ()) {
Cling cling = new Cling ();
; cling.setId (rs.getString (1));
cling.setCode (rs.getString (2));
cling.setName (rs.getString (3));
; cling.setAuthor (rs.getString (4));
list.add (cling);
}
close (rs);
close (pstmt);
} catch (SQLException e) {
close (rs);
close (pstmt);
rollback (conn);
} finally {
close (conn);
}
; return list;
}
4, Cling follows:
package manager.model;
public class Cling {
private String id, code, name, author;
public String getId () {
return id;
}
public void setId (String id) {
this.id = id ;
}
public String getCode () {
return code;
}
public void setCode (String code) {
this.code = code;
}
public String getName () {
return name;
}
public ; void setName (String name) {
this.name = name;
}
public String getAuthor () {
return author;
}
public void setAuthor (String author) {
this.author = author;
}
}
5, the configuration file is as follows:
< ; action type = "manager.action.ClingAction" scope = "request" path = "/ Cling / list">
<forward name = "success" path = "/ cling / cling.jsp" />
</action>

Sponsored Links

le2lea
2012-02-18 07:46:51
where you do not set in the ACTION attribute clings :
ClingDAO clingDAO = new ClingDAO (ds);
try {
; List clings = clingDAO.list ();
}
catch (SQLException e ) {
return actionMapping.findForward ("failure");
}
you look at add this okay
request.removeAttribute ("clings");
request.setAttribute ("clings", clings );

sprite95
2012-02-18 08:14:11
You forgot setAttribute in Action a
request.setAttribute ("clings", clings);
zxf33568948
2012-02-18 08:27:28
where you will not set clings ACTION attribute should be added:

request.setAttribute ("clings", clings);
yu422248586
2012-02-18 08:35:08
Thank you! I first try the!
tutusun
2012-02-18 08:49:41
still will not die! same problem!
cuilina320221
2012-02-18 09:04:13
Yes, this is the case, thank you heroes!
Domain and server ip had changed since 8/23/2013. Suspend the user registration and posts for program maintenance.