JSP开发中出现不能把age的String类型转换为int类型,可是我设置的明明就是int型的,什么问题呢?
int age = request.getParameter("Age");
总是这句报错。
<%
request.setCharacterEncoding("utf-8");
String sno = request.getParameter("Sno");
String sname = request.getParameter("Sname");
int age = request.getParameter("Age");
String sex = request.getParameter("Sex");
String sdept = request.getParameter("Sdept");
Student s = new Student(sno,sname,age,sex,sdept);
StudentDaoImpl sdi=new StudentDaoImpl();
if(sdi.deleteStudent(s)>0){
//response.sendRedirect("userlist.jsp");
out.print("<script type='text/javascript'>alert('成功删除此行记录!');</script>");
}
else
out.println("<script type='text/javascript'>alert('没有此用户');location.replace('userlist.jsp');</script>");
%>
建表和初始化都是整形,为什么会出现这种错误?
create table App.student(sno varchar(10),
sname varchar(40),
sex varchar(2),
age int,
sdept varchar(50),
primary key(sno));
public Student(String sno, String sname, int age,String sex, String sdept) {
super();
this.sno = sno;
this.sname = sname;
this.sex = sex;
this.age = age;
this.sdept = sdept;
}
开飞机的猛男
9 years, 6 months ago