안녕하세요 저는 홀수 또는 짝수 웹 서비스를 만들었고 netbeans에서 webservice에 대한 클라이언트를 maked했을 때이 오류가있었습니다. 여기에 웹 서비스 :java.lang.NumberFormatException : 입력 문자열 : "추가"
@WebService(serviceName = "Par_Impar")
public class Par_Impar {
/**
* Web service operation
*/
@WebMethod(operationName = "operation")
public String operation(@WebParam(name = "val") int val) {
if(val%2!=0){
//daca reminder-ul nu este 0 este impar
return("IMPAR");
}
else {
//daca reminder-ul este 0 atunci este par
return("PAR");
}
}
}
의 index.jsp :
<html>
<head>
<title>PAGINA JSP</title>
</head>
<body>
<form action="action.jsp" method="post"<br/>
Introdu numarul :<input type="text" name="nr"/><br/>
<input type="submit" value="Testeaza"/>
</form>
</body>
action.jsp는 :
<%--
Document : action
Created on : Apr 27, 2013, 5:28:45 PM
Author : ARB
--%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<h1>Hello World!</h1>
<%-- start web service invocation --%><hr/>
<%
String add=request.getParameter("numar");
int aa=Integer.parseInt("add");
try {
mypack.ParImpar_Service service = new mypack.ParImpar_Service();
mypack.ParImpar port = service.getParImparPort();
// TODO initialize WS operation arguments here
int val=aa;
// TODO process result here
java.lang.String result = port.operation(aa);
out.println("Result = "+result);
} catch (Exception ex) {
// TODO handle custom exceptions here
}
%>
<%-- end web service invocation --%><hr/>
</body>
</html>
제발 도와주세요. 고맙습니다 ! 라인 위
나는 int aa = Integer.parseInt (add)를 넣으려고 시도했다. 그리고 이것으로 내가 한 모든 것입니다. 왜냐하면 나는 이것에서 새롭고 많이 배울 필요가 있기 때문입니다. 이제 숫자를 입력하고 제출 버튼을 눌러 웹 서비스를 시작하면 결과는 다음과 같습니다. java.lang.NumberFormatException : null. 수정해야 할 부분을 보여 줄 수 있습니까? 답해 주셔서 감사합니다. 네가하는 일에 고맙다. 다시 한 번 감사드립니다! –
@ AndreiR.Beraru 나는'request.getParameter ("numar")'이 메소드가'null'을 리턴하고 있다고 생각하여 예외를 얻는다. –