- 论坛徽章:
- 0
|
- import java.io.*;
- import java.util.Enumeration;
- import javax.servlet.*;
- import javax.servlet.http.*;
- public class test extends HttpServlet {
- public void doGet (HttpServletRequest req, HttpServletResponse res)
- throws ServletException, IOException
- {
- String test = req.getParameter("test");
- PrintWriter out = res.getWriter();
- if(test==null){
- out.println("<form method=\"POST\" action=\"./test\">;");
- out.println(" <p>; <input type=\"text\" name=\"test\" size=\"20\">;<input type=\"submit\" value=\"submit\" name=\"B1\">;<input type=\"reset\" value=\"reset\" name=\"B2\">;</p>;");
- out.println("</form>;");
- }else out.println(test);
- }
- public String getServletInfo() {
- return "A simple servlet";
- }
- }
复制代码
如果test的值为中文的时候会出现:
type Status report
message HTTP method POST is not supported by this URL
description The specified HTTP method is not allowed for the requested resource (HTTP method POST is not supported by this URL).
请问怎么办才能接收中文参数? |
|