これは私のDB照会機能です
public static List<UserPass> selectAllUser() {
ConnectionPool pool = ConnectionPool.getInstance();
Connection connection = pool.getConnection();
PreparedStatement ps = null;
ResultSet rs = null;
List<UserPass> usersPass = new ArrayList<UserPass>();
String query = "select * from UserPass";
try{
ps = connection.prepareStatement(query);
rs = ps.executeQuery();
while(rs.next()){
UserPass users = new UserPass();
users.setUserName(rs.getString("user_name"));
usersPass.add(users);
}
return usersPass;
これは私のUserPassオブジェクト取得関数です
public ArrayList<UserPass> getusernames(){
return usernames;
}
私のサーブレットdopostは単にこれです
request.setAttribute("users", UserPassDb.selectAllUser());
String forward = "/testpage.jsp";
RequestDispatcher view = request.getRequestDispatcher(forward);
view.forward(request, response);
私の表示jspページは
<form action="TestServlet" method="post">
<input type="submit">
</form>
<c:forEach var="user" items="${users}">
<c:out value="${user.usernames}"/>
</c:forEach>
UserPass クラス
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package business;
import java.io.Serializable;
import java.util.ArrayList;
/**
*
* @author One
*/
public class UserPass implements Serializable {
public String username;
public String password;
public ArrayList<UserPass> usernames;
public UserPass(){
this.username ="";
this.password ="";
this.usernames = new ArrayList<UserPass>();
}
public void setUserName(String username) {
this.username = username;
}
public String getUserName(){
return username;
}
public ArrayList<UserPass> getusernames(){
return usernames;
}
public void setusernames(ArrayList<UserPass> a){
this.usernames = a;
}
}
これを変更しようとすると、私が理解している限り、プロパティが存在しないことがわかります。きっと間違っている
前もって感謝します