jsp出一点问题,进来看看!
代码如下:
<%@ page contentType= "text/html; charset=gb2312 " language= "java "
import= "java.sql.*,java.util.*,xuanke.* "
errorPage= " " %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN " "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<html xmlns= "http://www.w3.org/1999/xhtml ">
<head>
<meta http-equiv= "Content-Type " content= "text/html; charset=gb2312 " />
<title> 无标题文档 </title>
</head>
<jsp:useBean id= "kecheng " class= "xuanke.Kecheng "scope= "request "/>
<jsp:useBean id= "xuanke " class= "xuanke.Xuanke "scope= "request "/>
<jsp:useBean id= "kechengbean " class= "xuanke.KechengBean "scope= "request "/>
<jsp:useBean id= "xuankebean " class= "xuanke.XuankeBean "scope= "request "/>
<body>
<%
int score=0;
String sno=request.getParameter( "sno ");
String coursecode=request.getParameter( "coursecode ");
if(sno==null){
sno= " ";
}
if(coursecode==null){
coursecode= " ";
}
Xuanke xuankee=new Xuanke();
xuankee.setSno(sno);
xuankee.setCoursecode(coursecode);
Kecheng g=kechengbean.getKechengScore(coursecode);//这里是关键,
score=score+g.getCredithour();//不知正
xuankee.setScoresum(score);//不正确
try{
xuankebean.setXuanke(xuankee);
xuankebean.addXuanke();
}catch(Exception e)
{
out.println(e.getMessage());
}
%>
<center>
<h1>
添加选课成功
</h1>
</center>
<a href= "student.jsp "> 返回 </a>
</body>
</html>
相关的bean:
public Kecheng getKechengScore(String coursecode)throws Exception
{
Statement stmt=con.createStatement();
ResultSet result=stmt.executeQuery( "select * from kecheng where coursecode= ' "+coursecode+ " ' ");
while(result.next())
{
String coursecode1=result.getString( "coursecode ");
String coursename1=result.getString( "coursename ");
int credithour1=Integer.parseInt(result.getString( "credithour "));
int maxstudents1=Integer.parseInt(result.getString( "maxstudents "));
Kecheng ke=new Kecheng();