大家好,我有个问题如下

flytosky 05-02-24

大家好,我有个问题如下:

我写了个servlet如下, Tomcat is the servlet container


public class MyServlet extends HttpServlet{


public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
doPost(request, response);
}

public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {

System.out.println("a="+request.getParameter("a"));
}
}

当我调用该servlet的时候用

http://localhost:8080/test/myservlet?a=IeZzdf%2fbMaLr02%2bbjCqfpKeQoTva%2b4YxGz9Le42AhrCp0C9LXsyV6SHmc3X%2fzJXpIeZzdf%2fDmpyaw0XWohvZy6W7WkkST9dCRSdo4D%2bhNtlGknAA1pkQMDSVEimgxZ5jm5junBku5jzZUW4hCltNwe00jqeTifBckLwJBzryF3zOo4teM9GCH0eVabkL4c3%2bFs3kqBf

在System.out.println("a="+request.getParameter("a"));
应该打印出
a=IeZzdf%2fbMaLr02%2bbjCqfpKeQoTva%2b4YxGz9Le42AhrCp0C9LXsyV6SHmc3X%2fzJXpIeZzdf%2fDmpyaw0XWohvZy6W7WkkST9dCRSdo4D%2bhNtlGknAA1pkQMDSVEimgxZ5jm5junBku5jzZUW4hCltNwe00jqeTifBckLwJBzryF3zOo4teM9GCH0eVabkL4c3%2bFs3kqBf
但是所有有%的地方的部分字符串被截掉了,也就是说如果在Post的参数的值中含有%,
则在servlet中读到的参数字符串就会少有没有什么办法?
谢谢!

rasclewen
2005-02-25 09:29

问题是你这种
http://localhost:8080/test/myservlet?a=IeZzdf%2fbMaLr02%2bbjCqfpKeQoTva%2b4YxGz9Le42AhrCp0C9LXsyV6SHmc3X%2fzJXpIeZzdf%2fDmpyaw0XWohvZy6W7WkkST9dCRSdo4D%2bhNtlGknAA1pkQMDSVEimgxZ5jm5junBku5jzZUW4hCltNwe00jqeTifBckLwJBzryF3zOo4teM9GCH0eVabkL4c3%2bFs3kqBf

是get的方式,不是post呀!