Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/318.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 正在更改URL,但希望将数据发送到控制器_Java_Jsp_Servlets - Fatal编程技术网

Java 正在更改URL,但希望将数据发送到控制器

Java 正在更改URL,但希望将数据发送到控制器,java,jsp,servlets,Java,Jsp,Servlets,我的web应用程序有一个新的要求,即如果参数出现在url中,那么它将登陆到电子邮件页面。否则,像往常一样在索引页上。 这是一个非常旧的客户端产品,代码没有太大的变化空间,所以我设置了一个签入控制器,如果收到加密的电子邮件,就可以登录到电子邮件页面。 示例url- http://localhost:8080/R2/Controller?email=jAOtTv22BfkTkVrhTN/RHQ== 一切正常,但我想改变网址。 我怎样才能在URL中去掉“/Controller”,但它仍然指向Cont

我的web应用程序有一个新的要求,即如果参数出现在url中,那么它将登陆到电子邮件页面。否则,像往常一样在索引页上。 这是一个非常旧的客户端产品,代码没有太大的变化空间,所以我设置了一个签入控制器,如果收到加密的电子邮件,就可以登录到电子邮件页面。 示例url-

http://localhost:8080/R2/Controller?email=jAOtTv22BfkTkVrhTN/RHQ==
一切正常,但我想改变网址。 我怎样才能在URL中去掉“/Controller”,但它仍然指向Controller

控制器代码类似-

public class Controller extends HttpServlet {
static Logger logger = Logger.getLogger(Controller.class);

    protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
    try {
        // get the action property from the request
        String theAction = request.getParameter("action");
        String theSource = request.getParameter("s");
        String theSource1 = request.getParameter("email");

        String em ="";


        Action action=null;
       em = EncryptEmail.decrypt(theSource1,GFWConstants.BLOWFISH_KEY);

         if (em.equals(""))
                 rd = request.getRequestDispatcher("index.jsp?emailRtv=0");
             else
                 rd = request.getRequestDispatcher("email-preferences.jsp?emailRtv=2&emailAddress="+em);

             rd.forward(request,response);
             return;
         }

提前感谢。

向web.xml文件添加两个url模式有效。

更改web.xml中控制器的url模式如果我将在web.xml中更改,则许多页面无法工作,因为所有页面都无法登录到此页面。查看url重写过滤器或在web.xml中为servlet提供两个url模式