日期:2014-05-18  浏览次数:20767 次

用request接受的参数如何转换类型?
我用String   id=request.getParameter( "id ");接收表单传过来的值,我数据库里的id字段类型为INT的,如何转换呢?
因为我在JAVA文件里写的方法是:
public   void   update(ProductDetails   item)throws   Exception{
        String   sql= "update   test_procdcts   set   content= ' "+item.getContent()+ " '   where   id= "+item.getID()+ " ";

st.executeUpdate(sql);
}
我要的更新是content字段,它在数据库里的类型是varchar(250).
我在做后台里的新闻更新模块,这个更新问题老是还解决掉,很着急啊!

------解决方案--------------------
String idStr = request.getParameter( "id ");
int id = Integer.parseInt(idStr);