public User find(String username,String password){
try {
……………………
return user;
} catch (DocumentException e) {
// throw new RuntimeException(e);
e.printStackTrace();
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
会提示必须返回User类型的结果
而修改为
public User find(String username,String password){
try {
……………………
return user;
} catch (Exception e) {
throw new RuntimeException(e);
}
}
却没有报错,请问为什么?return语句不都是在try中吗?
try {
……………………
return user;
} catch (DocumentException e) {
// throw new RuntimeException(e);
e.printStackTrace();
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
会提示必须返回User类型的结果
而修改为
public User find(String username,String password){
try {
……………………
return user;
} catch (Exception e) {
throw new RuntimeException(e);
}
}
却没有报错,请问为什么?return语句不都是在try中吗?
解决方案 »
- Java泛型Spring2.5注入,产生异常,求关注。
- Servlet dwr-invoker is not available 问题
- 代码写了3年了,EJB还是没什么机会用,也没怎么搞懂。
- spring+ibatis整合的一个奇怪问题,问题解决给分
- action
- 郁闷的错误:ParserUtils: warning org.xml.sax.SAXParseException。请教
- hibernate取數據問題 在線等 解決給分
- 问题:hibernate+mysql innodb 数据没有保存到数据库中!!!!
- 高分求好的数据层封装源码,要求是不能使用entitybean的,不能封装sql的,只能是对jdbc友好封装.
- 有没有什么工具可以把两个或多个jar包打到一个jar包里去?
- 大家帮帮忙,关于Hibernate的,这怎么搞啊?
- 你知道吗?
…………
catch (DocumentException e) {
// throw new RuntimeException(e);
e.printStackTrace();
}
正常往下执行异常处理,并退出方法,需要返回值。