我使用以下代码来测试一个基本的Web服务。当我传递正常字符串时,例如 - http://localhost.com:8080/CheckRest/rest/pmg?p1=xyz。它显示HELLO xyz
但是,当我在URL中添加“#”时,它就不能正确输出,例如 - http://localhost.com:8080/CheckRest/rest/pmg?p1=xyz#abc。然后它会显示HELLO xyz而不是HELLO xyz#abc。
package com.check.ws;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
@Path("/pmg")
public class CheckCall {
@GET
@Produces(MediaType.TEXT_PLAIN)
public String sayPlainTextHello() {
return " ";
}
// This method is called if XML is request
@GET
@Produces(MediaType.TEXT_XML)
public String sayXMLHello() {
return "<?xml version=\"1.0\"?>" + "<pmg> </pmg>";
}
// This method is called if HTML is request
@GET
@Produces(MediaType.TEXT_HTML)
public String sayHtmlHello(@QueryParam("p1") String par1) {
return "<html> <body> HELLO </body> </html>"+par1;
}
}