2015-11-03 100 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

回答