You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

Overly_board_Catch.java 740 B

3 years ago
1234567891011121314151617181920212223242526272829303132333435363738394041
  1. package Overly_board_Catch;
  2. import java.util.logging.Logger;
  3. import javax.servlet.http.HttpServletRequest;
  4. public class Overly_board_Catch {
  5. static final Logger log = Logger.getLogger("logger");
  6. public void bad(HttpServletRequest request){
  7. String val = "1";
  8. try{
  9. int value = Integer.parseInt(val);
  10. if (value != 0) {
  11. log.info("parse ok");
  12. }
  13. }catch(Exception e){ // bad 犯化的捕获异常
  14. log.info("Exception");
  15. }
  16. }
  17. public void good(HttpServletRequest request) {
  18. String val = "1";
  19. try{
  20. int value = Integer.parseInt(val);
  21. if (value != 0) {
  22. log.info("parse ok");
  23. }
  24. }catch(NumberFormatException e){ // good 犯化的捕获异常
  25. log.info("NumberFormatException");
  26. }
  27. }
  28. }

No Description

Contributors (1)