servlet: error trying to convert string to int. throws NumberFormatException: For input String: "2/"

StackOverflow https://stackoverflow.com/questions/21276393

  •  01-10-2022
  •  | 
  •  

문제

my code in servlet is:

int gid = Integer.parseInt(request.getParameter("deleteid"));

where deleteid is hidden form field in jsp. The glassfish server log states that, java.lang.NumberFormatException: For input string: "2/"

도움이 되었습니까?

해결책

As its appending "/" after number I just used following method to solve the problem. Sorry for asking it at the first place:

int gid = Integer.parseInt(request.getParameter("deleteid").replaceAll("/"));

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top