混淆给定jsp文件的属性路径的值是什么

时间:2019-02-01 18:29:05

标签: spring spring-mvc jsp

这是我的表格结构

create database db_cms;
use db_cms;
create table course(coursecode varchar(5) primary key,coursename 
varchar(20),coursefees integer(20),coursetype varchar(20));
insert into course values('C1','Java',20000,'elearning');
insert into course values('C2','.Net',10000,'Both');
insert into course values('C3','Oracle',15000,'Both');
insert into course values('C4','Cloud',30000,'classroom');
insert into course values('C5','AI',40000,'classroom');
create table enrollstudent(enrollnumber integer(11) primary key 
auto_increment,coursetype varchar(20),gender varchar(6),studentname 
varchar(25),coursecode varchar(20) references course(coursecode));

学生Bean类

package com.bean;

public class Student {

    private int enrollNumber;
    private String studentName;
    private String gender;
    private String[] coursetype;
    private String coursecode;
    private int contact;
    public int getEnrollNumber() {
        return enrollNumber;
    }
    public void setEnrollNumber(int enrollNumber) {
        this.enrollNumber = enrollNumber;
    }
    public String getStudentName() {
        return studentName;
    }
    public void setStudentName(String studentName) {
        this.studentName = studentName;
    }
    public String getGender() {
        return gender;
    }
    public void setGender(String gender) {
        this.gender = gender;
    }
    public String[] getCoursetype() {
        return coursetype;
    }
    public void setCoursetype(String[] coursetype) {
        this.coursetype = coursetype;
    }
    public String getCoursecode() {
        return coursecode;
    }
    public void setCoursecode(String coursecode) {
        this.coursecode = coursecode;
    }
    public int getContact() {
        return contact;
    }
    public void setContact(int contact) {
        this.contact = contact;
    }
    @Override
    public String toString() {
        // TODO Auto-generated method stub
        return super.toString();
    }

}

课程豆类

package com.bean;

public class Course {

    private String coursecode;
    private String coursename;
    private int coursefees;
    private String coursetype;
    public String getCoursecode() {
        return coursecode;
    }
    public void setCoursecode(String coursecode) {
        this.coursecode = coursecode;
    }
    public String getCoursename() {
        return coursename;
    }
    public void setCoursename(String coursename) {
        this.coursename = coursename;
    }
    public int getCoursefees() {
        return coursefees;
    }
    public void setCoursefees(int coursefees) {
        this.coursefees = coursefees;
    }
    public String getCoursetype() {
        return coursetype;
    }
    public void setCoursetype(String coursetype) {
        this.coursetype = coursetype;
    }   


}

控制器类中的以下方法获取课程名称

@ModelAttribute("courseList")
    public Map<String,String> populateCourse() throws Exception{
    List<String> allCourses=service.getAllCourse();
    Map<String,String> courseMap=new HashMap<String,String>();
    for(String coursename:allCourses){
        courseMap.put(coursename,coursename);
    }       
    return courseMap;

}

此jsp页面用于生成用于为学生选择课程名称的下拉框,但是如果我给它提供课程名称,它将在学生班级中检查并且该属性未在学生班级中定义,我感到困惑。 / p>

<form:form name="stuForm1"  action="addStudent.htm" modelAttribute="student" method="GET" >
<h1>Course Enrollment</h1>
Student Name:<input type="text" name="studentname">
Course Name:<form:select path="coursecode">
            <form:options items="{courseList}"/>
            </form:select>
Gender: <form:radiobutton path="gender" value="M"/>Male
        <form:radiobutton path="gender" value="F"/>Female
Course Type:<form:checkbox path="coursetype" value="e-learning"/>e-learning
        <form:checkbox path="coursetype" value="classroom"/>classroom
        <input type="submit" value="Enroll"><br><br><br><br>
        <a href="">Back</a>
        </form:form>

0 个答案:

没有答案