论坛的页面
&……%……¥……
……&……%
你的帖子的名字 发帖人 回帖数 最后跟帖人 浏览量的话 不是所有论坛都有的功能
¥%……&(((
……&…………&
¥%&……&……
使用Java语言编写一个Servlet,从网页接收一个参数,将其设置为属性,然后将请求转发到另一个JSP页面,以显示该属性的值:
然后,在webxml文件中将Servlet映射到一个URL:
最后,在显示属性值的JSP页面上使用EL表达式来访问该属性的值:
当用户在网页上提交一个名为"inputValue"的参数时,该Servlet将获取该参数的值,并将其设置为名为"outputValue"的属性。然后,请求将被转发到名为"displayjsp"的JSP页面,该页面使用EL表达式"${outputValue}"来访问"outputValue"属性的值,并显示在页面上。
请注意,实际代码应该包括适当的错误处理和输入验证。
public class Student {
private String id;
private String name;
private boolean sex;
private String age;
private String mobile;
private String address;
public Student() {
}
public Student(String id, String name) {
thisid = id;
thisname = name;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
thisaddress = address;
}
public String getAge() {
return age;
}
public void setAge(String age) {
thisage = age;
}
public String getId() {
return id;
}
public void setId(String id) {
thisid = id;
}
public String getMobile() {
return mobile;
}
public void setMobile(String mobile) {
thismobile = mobile;
}
public String getName() {
return name;
}
public void setName(String name) {
thisname = name;
}
public boolean isSex() {
return sex;
}
public void setSex(boolean sex) {
thissex = sex;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != ogetClass()) return false;
Student student = (Student) o;
if (!idequals(studentid)) return false;
return true;
}
@Override
public int hashCode() {
return idhashCode();
}
@Override
public String toString() {
return "Student{" +
"address='" + address + '\'' +
", id='" + id + '\'' +
", name='" + name + '\'' +
", sex=" + sex +
", age='" + age + '\'' +
", mobile='" + mobile + '\'' +
'}';
}
}public class StudentManager {
private Vector<Student> students;
private int number;
public StudentManager() {
students = new Vector<Student>();
number = 0;
}
public void addStudent(Student student) {
if (studentscontains(student)) {
Systemoutprintln("学号为" + studentgetId() + "的学生已经存在,不能有相同学号的学生。");
return;
}
if (studentsadd(student)) {
Systemoutprintln("添加学生成功:" + student);
number++;
}
}
public void deleteStudent(Student student) {
if (studentsremove(student)) {
Systemoutprintln("成功删除学号为" + studentgetId() + "的学生");
number--;
}
}
public void modifyStudent(Student student) {
if (studentsremove(student)) {
studentsadd(student);
Systemoutprintln("成功修改学号为" + studentgetId() + "的学生,新学生的信息为" + student);
} else {
Systemoutprintln("不存在学号为" + studentgetId() + "的学生");
}
}
public void printStudents() {
Enumeration<Student> enumeration = studentselements();
while (enumerationhasMoreElements()) {
Systemoutprintln(enumerationnextElement());
}
}
public int getNumber() {
return number;
}
}public class TestStudentManager {
public static void main(String[] args) {
StudentManager manager = new StudentManager();
Student student1 = new Student("001", "xiaowang");
Student student2 = new Student("002", "xiaohong");
manageraddStudent(student1);
manageraddStudent(student2);
Systemoutprintln("学生个数:" + managergetNumber());
managerprintStudents();
// a student with same id, cannot be added to manager
Student student3 = new Student("002", "xiaohong2");
manageraddStudent(student3);
Systemoutprintln("学生个数:" + managergetNumber());
managerprintStudents();
managerdeleteStudent(student1);
Systemoutprintln("学生个数:" + managergetNumber());
managerprintStudents();
Student student4 = new Student("002", "xiaohong2");
student4setAge("25");
managermodifyStudent(student4);
Systemoutprintln("学生个数:" + managergetNumber());
managerprintStudents();
}
}
数据库中的number类型在java类对应的类型:
1如果number类没有设置小数位位数,默认小数位数为0,则在java类中可以使用int或者long对应;
2如果number类设置小数位位数,在java类中可以使用double类进行对应。
注:也可以使用基本类型的包装类进行对于,比如double的包装类为Double
以上就是关于怎么看帖子的浏览率全部的内容,包括:怎么看帖子的浏览率、java Web编程技术作业求帮助,谢谢
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)