jsp其实是一个java类

我们打开tomcat的D:Program_Filesapache-tomcat-8.0.32workCatalinalocalhostvenusorgapachejsp,

当我们访问过页面后会发现login.jsp会生成两个文件login_jsp.class和login_jsp.java

我们打开java文件其中有这段代码

out.write(" ");
out.write("<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> ");
out.write("<html> ");
out.write(" <head> ");
out.write(" <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> ");
out.write(" <title>百度一下</title> ");
out.write(" </head> ");
out.write(" <body> ");
out.write(" <form action="./DoLoginServlet" method="post"> ");
out.write(" <input name="user_name"> ");
out.write(" <input type="password" name="password"> ");
out.write(" <button type="submit">提交</button> ");
out.write(" </form> ");
out.write(" ");
out.write(" </body> ");
out.write("</html>");

发现原理JSP里的内容变成了字符串

JSP文件是在一个类中的

原文地址:https://www.cnblogs.com/lyxcode/p/9458478.html