2015-11-03 69 views
0

我应该发展与球衣休息Web服务来解析以下网址: http://localhost:8080/userApp/processMsg/request?Username= $用户名&名字= $ lastName的&消息= $消息&的SessionID = $的sessionId为什么在网址中忽略号码符号?

我用下面的代码和工作正常:

@POST 
@Path("/request") 
@Produces(MediaType.APPLICATION_XML + ";charset=utf-8") 
public UserResponse getUsers(@QueryParam("Username") String Username, 
           @QueryParam("LastName") String LastName, 
           @QueryParam("Message") String Message, 
           @QueryParam("SessionId") String SessionId 
) { 

    // my code 
} 

我的问题是,当我有URL中的'#'字符,在这种情况下,从这个字符到URL的结尾,将被忽略。我无法对网址格式进行任何更改,并且#符号始终存在于邮件字段的末尾。 为避免这一点,我添加了一个过滤器,以我的web.xml,使用此代码:

public void doFilter(ServletRequest request, ServletResponse response, FilterChain  next) 
     throws IOException, ServletException 
{ 
    // Respect the client-specified character encoding 
    // (see HTTP specification section 3.4.1) 
    if(null == request.getCharacterEncoding()) 
     request.setCharacterEncoding(encoding); 


    /** 
    * Set the default response content type and encoding 
    */ 
    response.setContentType("text/html; charset=UTF-8"); 
    response.setCharacterEncoding("UTF-8"); 


    next.doFilter(request, response); 
} 

但request.getParameterMap的值()是相同的前面的,并没有结束的url 。例如,当我在网址: http://localhost:8080/userApp/processMsg/request?Username= $测试&名字= $ test2的&消息= $的HelloWorld#&的SessionID = $ 123456,什么网址收到我的申请是: http://localhost:8080/userApp/processMsg/request?Username= $测试&名字= $ test2的&消息= $ HelloWorld

我该如何处理这个问题?

+0

你是否得到它的工作?如果是这样,你能接受我的回答吗? – Filip

回答