JspServlet中的“mappedfile”参数代表什么?

时间:2016-06-02 08:06:16

标签: jsp tomcat servlets

我正在阅读https://tomcat.apache.org/tomcat-7.0-doc/jasper-howto.html

有参数:

  

mappedfile - 我们是否应该为每个输入行生成一个print语句的静态内容,以便于调试?是或否,默认   真。

但我无法理解这个参数的详细用法是什么,我试图谷歌但没有帮助。有人可以告诉我它是什么。

1 个答案:

答案 0 :(得分:6)

mappedfile为真时,容器会生成" out.print()"对于JSP文件中的每个HTML文本行。如果为false,则将来自多行的HTML文本连接起来并输出到一个" out.print()"这就是它如何简化调试。

<JspInterceptor mappedFile="true" />容器生成如下内容时:

out.write("<!DOCTYPE html>\r\n");
out.write("<html>\r\n");
out.write("<head>\r\n");
out.write("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">\r\n");
out.write("<title>Test</title>\r\n");
out.write("</head>\r\n");

<JspInterceptor mappedFile="false" />这样的事情发生时:

out.write("<!DOCTYPE html><html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"><title>Index</title></head>");

较早版本的tomcat (3,4)默认情况下具有此选项false,而从tomcat 5开始的较新版本默认使用此选项true