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

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

  •  01-10-2022
  •  | 
  •  

Question

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/"

Était-ce utile?

La solution

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("/"));

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top