사용자가 URL을 입력 할 때 전달 된 매개 변수를 검색하는 데 도움이 필요합니다. http://localhost:8182/trace/abc/def?param=123 매개 변수가 전달 된 곳은 123입니다. 123을 표시하려면 어떻게해야합니까?url에 전달 된 매개 변수를 검색하여 restlet을 사용하여 웹 브라우저에서 값을 반환
Part05
import org.restlet.Component;
//import org.restlet.Server;
import org.restlet.data.Protocol;
import org.restlet.resource.Get;
import org.restlet.resource.ServerResource;
public class Part05 extends ServerResource {
public static void main(String[] args) throws Exception {
// Create the HTTP server and listen on port 8182
//new Server(Protocol.HTTP, 8182, Part05.class).start();
// TODO Auto-generated method stub
// Create a new Restlet component and add a HTTP server connector to it
Component component = new Component();
component.getServers().add(Protocol.HTTP, 8182);
// Then attach it to the local host
component.getDefaultHost().attach("/trace", Part05.class);
// Now, let's start the component!
// Note that the HTTP server connector is also automatically started.
component.start();
}
@Get
public String toString() {
// Print the requested URI path
return "Resource URI : " + getReference() + '\n' + "Root URI : "
+ getRootRef() + '\n' + "Routed part : "
+ getReference().getBaseRef() + '\n' + "Remaining part: "
+ getReference().getRemainingPart() ;
} }
홈페이지
import org.restlet.Component;
import org.restlet.data.Protocol;
public class Main {
/**
* @param args
*/
public static void main(String[] args) throws Exception
{
// TODO Auto-generated method stub
// Create a new Restlet component and add a HTTP server connector to it
Component component = new Component();
component.getServers().add(Protocol.HTTP, 8182);
// Then attach it to the local host
component.getDefaultHost().attach("/trace", Part05.class);
// Now, let's start the component!
// Note that the HTTP server connector is also automatically started.
component.start();
}}
: 웹 browser.Which 자바 클래스 내가 검색 한 웹 페이지의 매개 변수를 반환하기 위해 변경해야합니다 여기에
내가 가지고있는 코드는 내가 가진3210
출력 : 자원 URI : http://localhost:8182/trace/abc/def?param=123 남은 부분은 :/ABC/DEF PARAM = 123
도움이 절실히 필요합니다! 감사