JSP中如何将String型转换为int型啊

request.setCharacterEncoding("GBK");
String topicId=request.getParameter("topicId");
我要将topicId作为参数放在toTopic()方法里面,但参数要求是整型,请问下怎么才能转换

int topicId=Integer.ValueOf(request.getParameter("topicId"));
温馨提示:答案为网友推荐,仅供参考
第1个回答  2009-03-28
Integer.parseInt(topicld);
第2个回答  2009-03-28
int i = Integer.parseInt(topicld);
注意判断topicld是否为空。
否则出异常
第3个回答  2009-03-28
int inttopicld = Integer.parseInt(topicld);
相似回答