读书人

JavaWeb 打开时分不现实

发布时间: 2013-12-10 15:05:55 作者: rapoo

JavaWeb 打开时候不现实

<%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">

<title>My JSP 'index.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>

<body>
<c:forEach items="${requestScope.ls}" var="bean" varStatus="beanStatus">
<tr>

<td>${bean.Id}</td>
<td>${bean.Nmae}</td>
<td>${bean.Pwd}</td>
<td>${bean.Age}</td>
</tr>
</c:forEach>
</body>
</html>

package servelt;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import shiti.st;

import dao.daostudent;

public class servlet extends HttpServlet {

/**
* Constructor of the object.
*/
public servlet() {
super();
}

/**
* Destruction of the servlet. <br>
*/
public void destroy() {
super.destroy(); // Just puts "destroy" string in log
// Put your code here
}

/**
* The doGet method of the servlet. <br>
*
* This method is called when a form has its tag value method equals to get.
*
* @param request the request send by the client to the server
* @param response the response send by the server to the client
* @throws ServletException if an error occurred
* @throws IOException if an error occurred
*/
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {

daostudent ds = new daostudent();
List<st> ls = new ArrayList<st>();
request.setAttribute("xsl",ls);
request.getRequestDispatcher("index.jsp").forward(request, response);
}

/**
* The doPost method of the servlet. <br>
*
* This method is called when a form has its tag value method equals to post.
*
* @param request the request send by the client to the server
* @param response the response send by the server to the client
* @throws ServletException if an error occurred
* @throws IOException if an error occurred
*/
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {

doGet(request, response);
}

/**
* Initialization of the servlet. <br>
*
* @throws ServletException if an error occurs


*/
public void init() throws ServletException {
// Put your code here
}

}


JavaWeb?JSP?错误
[解决办法]
什么意思?看不懂
怎么用页面打开什么都没有,text打开可以测试能得到数据?
[解决办法]
javax.el.PropertyNotFoundException: Property 'Id' not found on type shiti.st
daostudent 这个里面有id属性吗

[解决办法]
好像没对数据库进行访问,Is为空。
[解决办法]
ls是什么对象,
没有id属性?或者就是没有get方法

读书人网 >Java Web开发

热点推荐