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