以下代码为什么报错?
package test.java.course;
public class Crouse {
public int id;
public String name;
public String category;
public Crouse (int id,String name,String category) {
this.id=id;
this.category=category;
this.name=name;
};
public Crouse() {
// TODO Auto-generated constructor stub
}
/**
* @return the id
*/
public int getId() {
return id;
}
/**
* @param id the id to set
*/
public void setId(int id) {
this.id = id;
}
/**
* @return the name
*/
public String getName() {
return name;
}
/**
* @param name the name to set
*/
public void setName(String name) {
this.name = name;
}
/**
* @return the category
*/
public String getCategory() {
return category;
}
/**
* @param category the category to set
*/
public void setCategory(String category) {
this.category = category;
}
/* (non-Javadoc)
* @see java.lang.Object#toString()
*/
@Override
public String toString() {
return "Crouse [id=" + id + ", name=" + name + ", category=" + category + "]";
}
}
package test.java.course;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* Servlet implementation class CourseServlet
*/
@WebServlet(description = "12", urlPatterns = { "/CourseServlet11" })
public class CourseServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
* @see HttpServlet#HttpServlet()
*/
public CourseServlet() {
super();
// TODO Auto-generated constructor stub
}
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
Crouse core=new Crouse();
// request.setAttribute("course", course);
core.setId(1);
core.setName("liu");
//core.setCategory("编程"");
request.getRequestDispatcher("/cp.jsp").forward(request, response);
}
}
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>tese</title>
</head>
<body>
<h1>课程id:${requestScope.course.id }</h1>
<h1>课程名称:${requestScope.course.getName() }</h1>
<h1>课程方向:${requestScope.crourse.getCategory() }</h1>
</body>
</html>
正在回答 回答被采纳积分+1
- 参与学习 人
- 提交作业 357 份
- 解答问题 8016 个
本阶段将带你学习MySQL数据库,JDBC接口,MyBatis框架等,带你掌握的数据的存放和管理。
了解课程
恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧
0 星