本文共 438 字,大约阅读时间需要 1 分钟。
String类型转化成int类型,不论哪种情况,在java中都能转化。
无论是在domain实体类中,还是在Dao(数据访问层),Service层(服务层)也行。 除去强制转换,项目开发总一共还有两种方法public void getPost(HttpServletRequest request){String str = request.getParameter("classId");//方法一 int classId = Integer.parseInt(request.getParameter("classId"));//方法二int classId2 = Integer.ValueOf("classId").intValue();...}
在写小的案例的时候,是需要用try…catch来捕捉异常的,这时因为传过来的classId可能包含非数字的,但是在实际项目中,这写传入的参数的类型标准化传入的,没有用到异常。
转载地址:http://awtml.baihongyu.com/