Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
为什么我们不能使用 System.out.println(); 在jsp声明元素里面?当我尝试编写该行时,显示编译器错误。
<%!System.out.println("test") %> <body> <form action="FindPhone" method="post"> PhoneNumber : <input type="text" name="phone"> <input type="submit" value="submit"> </form>
因为声明元素转换为 JSP 生成的类中的字段声明:
public class GeneratedJsp extends JspServlet { System.out.println("test"); }
不是有效的 Java 代码。一个声明元素应该包含……一个声明。