친애하는 Stackoverflow 사용자, 나는 꽤 오랫동안 편안한 웹 서비스로 놀아 왔습니다. GET 메서드를 사용하여 매개 변수를 전달하는 방법에 대해 의문의 여지가 있습니다. get는 리소스를 검색하는 데만 사용할 수 있으므로 매개 변수를 전달하는 방법은 무엇입니까? 작은 코드를 작성했지만 코드에 문제가있는 것 같습니다.편안한 웹 서비스에서 매개 변수 전달하기
@GET
@Produces("text/plain")
@Path("/instrumentname/")
public String getname(String name1) {
try {
String [] env=null;
String[]callAndArgs= {"python","connection.py",ins_name};//passing the parameters
Process p = Runtime.getRuntime().exec(callAndArgs,env,
new java.io.File("C:\\Users\\Balkishore\\Documents\\NetBeansProjects\\Testinstrument_Rest\\build\\web"));//excuting the python file
BufferedReader stdInput = new BufferedReader(new
InputStreamReader(p.getInputStream()));//getting the input
BufferedReader stdError = new BufferedReader(new
InputStreamReader(p.getErrorStream()));//getting the error
interface_name = stdInput.readLine();//reading the output
System.out.println(interface_name);
}
catch (IOException e) {//catching the exception
System.out.println("exception occured");
e.printStackTrace();
System.exit(-1);
}
return this.interface_name;
}
어떤 도움을 주시면 감사하겠습니다. 미리 감사드립니다. 건배!
답장을 보내 주셔서 감사합니다. 하지만 내 서버에 연결된 자바 클라이언트가 있다면 어떻게 될까? 이 경우 URL을 통해 매개 변수를 전달할 수 없습니다. 내 GET 메소드에 매개 변수를 삽입하는 방법은 무엇입니까? 위의 코드에서 매개 변수를 전달하기 위해 수행 할 수있는 작업이 없으면 어떻게해야합니까? 도움말은 대단히 감사하겠습니다. 미리 감사드립니다. – Spaniard89
그리고 나는 데이터베이스를 사용하지 않고 있습니다. – Spaniard89
이 코드는 서버 측 코드입니다. 이제 클라이언트에서 서버로 매개 변수를 전달하는 방법을 알고 싶습니까 ?? 또는이 함수의 매개 변수를 쉘 명령으로 호출하는 python 스크립트로 전달하는 방법을 알고 싶습니까? – hjindal