我写了一个HTML代码在JSP中,是一个form表单,可以提交到数据库,而我用doget方法把年龄读出来了,但是之前我在JAVA中定义的是int型,而从html中取到doget中时,是string型,想到这个String型的数字存到之前我定义的那个INT型的变量中,我应该如何改换类型 呢?protected void doGet(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
String username = request.getParameter("username");
String password = request.getParameter("password");
String age = request.getParameter("age");
String interesting = request.getParameter("interesting");
String description = request.getParameter("description");
Cotroller oneCotroller = new Cotroller();//定义一个Cotroller类的oneCotroller变量,那么这个oneCotroller就可以调用Cotroller中的方法。
Userinformation userinformation = new Userinformation();
userinformation.setUsername(username);
userinformation.setPassword(password);
userinformation.setAge(age)
//这个地方有错,
The method setAge(int) in the type Userinformation is not applicable for the arguments (String) myfirtweb/src/com/qinghe/test ZHUCE.java line 48 1215662941843 877 userinformation.setInteresting(interesting);
谢谢前辈们指点!
HttpServletResponse response) throws ServletException, IOException {
String username = request.getParameter("username");
String password = request.getParameter("password");
String age = request.getParameter("age");
String interesting = request.getParameter("interesting");
String description = request.getParameter("description");
Cotroller oneCotroller = new Cotroller();//定义一个Cotroller类的oneCotroller变量,那么这个oneCotroller就可以调用Cotroller中的方法。
Userinformation userinformation = new Userinformation();
userinformation.setUsername(username);
userinformation.setPassword(password);
userinformation.setAge(age)
//这个地方有错,
The method setAge(int) in the type Userinformation is not applicable for the arguments (String) myfirtweb/src/com/qinghe/test ZHUCE.java line 48 1215662941843 877 userinformation.setInteresting(interesting);
谢谢前辈们指点!
解决方案 »
- java 多线程在竞争一个内部锁时,只有一个线程获得锁,其它线程状态是什么?
- javac:需要}
- 怎么利用repaint()和rotate实现路径旋转的效果
- 高手帮忙看看我下面代码问什么 编译不通过哪!!
- Struts 中的M???????????
- 一个关于两次使用rs的问题?
- 变量退出作用域是会自动析构吗?
- java通过jdbc使用oracle的一个错误,高手请进
- String a="123"与String a=new String("123")出来的两个a,b之间有什么区别???
- Sun中国公司据说今年效益不好,连新年的会餐费也没有了?!
- 寻java面试题,java刚学完,想做一些面试的题目
- Eclipse问题
楼主【chenlei8812】截止到2008-07-10 12:21:56的历史汇总数据(不包括此帖):
发帖的总数量:3 发帖的总分数:80 每贴平均分数:26
回帖的总数量:3 得分贴总数量:0 回帖的得分率:0%
结贴的总数量:3 结贴的总分数:80
无满意结贴数:0 无满意结贴分:0
未结的帖子数:0 未结的总分数:0
结贴的百分比:100.00% 结分的百分比:100.00%
无满意结贴率:0.00 % 无满意结分率:0.00 %
敬礼!
int age = (s == null) ? 0 : Integer.parseInt(s);
throws NumberFormatException
{
if (s == null) {
throw new NumberFormatException("null");
} if (radix < Character.MIN_RADIX) {
throw new NumberFormatException("radix " + radix +
" less than Character.MIN_RADIX");
} if (radix > Character.MAX_RADIX) {
throw new NumberFormatException("radix " + radix +
" greater than Character.MAX_RADIX");
} int result = 0;
boolean negative = false;
int i = 0, max = s.length();
int limit;
int multmin;
int digit; if (max > 0) {
if (s.charAt(0) == '-') {
negative = true;
limit = Integer.MIN_VALUE;
i++;
} else {
limit = -Integer.MAX_VALUE;
}
multmin = limit / radix;
if (i < max) {
digit = Character.digit(s.charAt(i++),radix);
if (digit < 0) {
throw NumberFormatException.forInputString(s);
} else {
result = -digit;
}
}
while (i < max) {
// Accumulating negatively avoids surprises near MAX_VALUE
digit = Character.digit(s.charAt(i++),radix);
if (digit < 0) {
throw NumberFormatException.forInputString(s);
}
if (result < multmin) {
throw NumberFormatException.forInputString(s);
}
result *= radix;
if (result < limit + digit) {
throw NumberFormatException.forInputString(s);
}
result -= digit;
}
} else {
throw NumberFormatException.forInputString(s);
}
if (negative) {
if (i > 1) {
return result;
} else { /* Only got "-" */
throw NumberFormatException.forInputString(s);
}
} else {
return -result;
}
} public static int parseInt(String s) throws NumberFormatException {
return parseInt(s,10);
}
Duplicate local variable age myfirtweb/src/com/qinghe/test ZHUCE.java line 38 1215665734265 885