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