简体   繁体   English

如何包含JSP文件

[英]How to include jsp files

--webapp
     --WEB-INF
         --web.xml
     --index.jsp
     --jsp
         --Example.jsp

I am using javax.servlet 我正在使用javax.servlet

As I know ,the index.jsp is under the of webapp . 据我所知,index.jsp在webapp的下面。

But when I want to redirect to the Example.jsp ,It says could not found ... 但是当我想重定向到Example.jsp时,它说找不到...

How can I make it work?configure the pom.xml or the web.xml? 如何使其工作?配置pom.xml或web.xml?

web.xml like this 像这样的web.xml

<servlet>
    <servlet-name>GetAccess</servlet-name>
    <servlet-class>com.dodopipe.karl.GetAccess</servlet-class>
</servlet>
<servlet-mapping>
    <servlet-name>GetAccess</servlet-name>
    <url-pattern>/GetAccess</url-pattern>
</servlet-mapping>

GetAccess.java GetAccess.java

RequestDispatcher rd = request.getRequestDispatcher("/Example.jsp");
rd.forward(request, response);

Your Example.jsp is under jsp folder, so your Request Dispatcher should be like this: 您的Example.jsp位于jsp文件夹下,因此您的Request Dispatcher应该如下所示:

RequestDispatcher rd = request.getRequestDispatcher("jsp/Example.jsp");
rd.forward(request, response);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM