私はストラットが初めてです。jsp 上のデータベース内のテーブルのすべての詳細をユーザーに表示したいと考えています。これらを行う際に私を助けてください。
前もって感謝します、ヴィディア
LoginFormBean.java
public class LoginFormBean extends ValidatorForm
{
public String name;
public String city;
public String state;
public String phone;
public String mailId;
public String gender;
public String branch;
private List studentDetails;
public void setName(String name) {
this.name = name;
}
public String getName() {
return name;
}
public void setCity(String city) {
this.city = city;
}
public String getCity() {
return city;
}
public void setPhone(String phone) {
this.phone = phone;
}
public String getPhone() {
return phone;
}
public void setMailId(String mailId) {
this.mailId = mailId;
}
public String getMailId() {
return mailId;
}
public void setGender(String gender) {
this.gender = gender;
}
public String getBranch() {
return branch;
}
public void setBranch(String branch) {
this.branch = branch;
}
public String getGender() {
return gender;
}
public void setState(String state) {
this.state = state;
}
public String getState() {
return state;
}
public List getStudentDetails() {
return studentDetails;
}
public void setStudentDetails(List studentDetails) {
this.studentDetails = studentDetails;
}
}
Logindao.java
public class Logindao {
public List viewStudents()
{
Connection conn=DBUtil.getDBConnection();
List list=new ArrayList();
Statement stmt = null;
ResultSet rs=null;
String query="select * from student_info";
stmt=conn.createStatement();
rs= stmt.executeQuery(query);
while(rs.next())
{
list = new ArrayList();
list.add(rs.getString("name"));
list.add(rs.getString("phone"));
list.add(rs.getString("email"));
list.add(rs.getString("city"));
list.add(rs.getString("state"));
list.add(rs.getString("gender"));
list.add(rs.getString("branch"));
}
}
return list;
}
RetrieveDataActionClass.java
public class RetrieveDataActionClass extends Action{
public ActionForward execute(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response)throws Exception,ServletException
{
List list=new ArrayList();
String key="success";
Logindao dao=new Logindao();
LoginFormBean formbean=(LoginFormBean)form;
try{
list=dao.viewStudents();
formbean.setStudentDetails(dao.viewStudents());
}
catch(Exception e)
{
e.printStackTrace();
System.out.println("Error occured");
}
return mapping.findForward(key);
}
}
viewstudents.jsp
<body>
<html:form action="/retrieve" method="post">
<table border="1">
<tr>
<th>Name</th>
<th>Phone</th>
<th>MailId</th>
<th>City</th>
<th>State</th>
<th>Gender</th>
<th>Branch</th>
</tr>
<logic:iterate id="students" name="LoginFormBean" property="studentDetails">
<tr>
<td><bean:write name="students" property="name"/></td>
<td><bean:write name="students" property="phone"/></td>
<td><bean:write name="students" property="mailId"/></td>
<td><bean:write name="students" property="city"/></td>
<td><bean:write name="students" property="state"/></td>
<td><bean:write name="students" property="gender"/></td>
<td><bean:write name="students" property="branch"/></td>
</tr>
</logic:iterate>
</table>
</html:form>
</body>
sqlserver データベースにテーブル ' student_info ' があります。列:名前、電話番号、電子メール、都市、都道府県、性別、支店
出力をjspで以下の形式で表示したい。
名前 電話 メール 都市 州 性別 支店
abc 55555 a@gmail.com hyd AP 女性 IT
xyz 55555 x@gmail.com bang KT 女性 CSE
エラー:
javax.servlet.ServletException: javax.servlet.jsp.JspException: Bean が見つかりません: "LoginFormBean" がどのスコープにもありません
前もってありがとう、Vidya。