我想让学分字段进入文本里,高手看看!
最近用JSP在做一个选课系统,哪位仁兄做过,帮帮忙!
我数据库里有表:student(studentcode,name,sex,password)
kecheng(coursecode,coursename,credithour,maxstudents)
xuanke(studentcode,coursecode,scoresum)
现在选课出了点问题,在一个界面中通过下拉列表选择学号,课程号,
我想让学分自动的跳出来,因为一门课程的学分是固定的.
我用二层模型!出现问题的代吗如下:
<%@ 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= "student " class= "xuanke.Student "scope= "request "/>
<jsp:useBean id= "studentbean " class= "xuanke.StudentBean "scope= "request "/>
<jsp:useBean id= "kecheng " class= "xuanke.Kecheng "scope= "request "/>
<jsp:useBean id= "kechengbean " class= "xuanke.KechengBean "scope= "request "/>
<body>
<center>
<form name= "form2 " method= "post " action= "xuanke_do.jsp ">
<table width= "415 ">
<tr>
<td width= "233 " height= "40 "> 请选择学号:
<select name= "studentcode ">
<%
Collection t=studentbean.getStudent();
Iterator it=t.iterator();
while(it.hasNext())
{
Student stu=(Student)it.next();
out.println( " <option value= "+stu.getSno()+ "> "+stu.getName()+ " </option> ");
}
%>
</select> </td>
<td width= "170 " height= "26 "> 请选择课程:
<select name= "coursecode ">
<%
Collection f=kechengbean.getKecheng();
Iterator its=f.iterator();
while(its.hasNext())
{
Kecheng stu=(Kecheng)its.next();
out.println( " <option value= "+stu.getCoursecode()+ "> "+stu.getCoursename()+ " </option> ");
}
%>
</select>
</td>
<td>
<%
//kechengbean.getKechengScore((String)request.getParamet( "coursecode "));
String course=request.getParameter( "coursecode ");//注意:我不知道这条语句能不能获得上面select课程号中的 "coursecode "
Kecheng g=kechengbean.getKechengScore( "course ");
%>
<input name= "password " type= "text " values= " <%=g.getCredithour()%> " size= "15 " />
</td>
</tr>
<center> <tr> <td> <center> <input type=submit value=提交 > </center> </td> </tr>
</table>
</form>
</center>
</body>
</html>
[解决办法]
用String course=rs.getString( "coursecode ");
[解决办法]
String course=request.getParameter( "coursecode ");//注意:我不知道这条语句能不能获得上面select课程号中的 "coursecode "
试一下不就得了
但总之,这种方式必须是要提交一下才能出来。
要自动即时出来,只能用AJAX了。