JSP链接到另一个JSP [英] JSP link to another JSP

查看:81
本文介绍了JSP链接到另一个JSP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的JSP页面中,我希望链接转发到另一个JSP页面.当用户位于home.jsp上时,我希望他们进入login.jsp等.我遇到的问题是,除非将页面放在项目文件夹中(WEB-INF上方),否则找不到JSP.文件夹).

In my JSP page I want the links to forward to another JSP page. When the user is on the home.jsp I want them to go to login.jsp etc. The problem I am having is that the JSP can't be found except when i put the pages in the project folder (above the WEB-INF folder).

我尝试了以下代码行,但没有用:

I tried these lines of code, but none worked:

<a href="/enq/WEB-INF/pages/login.jsp">
<a href="/WEB-INF/pages/login.jsp">
<a href="/pages/login.jsp">

它仅与项目文件夹中的JSP页面一起使用,然后使用下一行:

It is only working with the JSP pages in the project folder and then I use the next line:

<a href="login.jsp">

但是我希望JSP页面位于:WEB-INF/pages/

But I want the JSP pages to be in: WEB-INF/pages/

推荐答案

我已经解决了这个问题,我为每个JSP页面创建了4个Servlet.每个servlet都将消息转发到相应的JSP,如下所示:

I have solved it, I have created 4 Servlets for each JSP page. Every servlet forwards the message to the corresponding JSP like this:

request.getRequestDispatcher("/WEB-INF/pages/enquette.jsp").forward(request, response);

并且在JSP页面中的a href之间:

And in the JSP page in between the a href :

<a href="/enq/enquette">

网络XML:

<servlet-mapping>
<servlet-name>Enquette</servlet-name>
<url-pattern>/enquette</url-pattern>

这篇关于JSP链接到另一个JSP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆