【问题标题】:The method print(boolean) in the type JspWriter is not applicable for the arguments [duplicate]JspWriter 类型中的方法 print(boolean) 不适用于参数 [重复]
【发布时间】:2016-05-03 06:42:54
【问题描述】:

我想打印函数返回的字符串值。

但我得到了错误,即使是这个简单的过程。

错误:

org.apache.jasper.JasperException: Unable to compile class for JSP: 

An error occurred at line: 16 in the jsp file: /beansal.jsp
The method print(boolean) in the type JspWriter is not applicable for the arguments (void)
13: </head>
14: <body>
15: <%String s = new DBConnectionTest().Test();%>
16: <%=System.out.println(s)%>
17: <jsp:getProperty name="person" property="name"></jsp:getProperty>&nbsp;
18: <jsp:getProperty name="person" property="lastName"></jsp:getProperty>
19: </body>

【问题讨论】:

    标签: java jsp


    【解决方案1】:

    在你的代码: 16: &lt;%=System.out.println(s)%&gt;

    这将是 16: &lt;%=s %&gt;

    因为它被解释为&lt;% out.print(s) %&gt;

    【讨论】:

    • 我做到了。错误 org.apache.jasper.JasperException: 在第 16 行处理 JSP 页面 /beansal.jsp 时发生异常 13: 14: 15: 16: 17:   18: 19:
    • DBConnectionTest 在任何包下?
    • 添加.. &lt;%@ page import="mypackage.DBConnectionTest" %&gt; 。不在任何包下的类,jsp有时会找不到。
    猜你喜欢
    • 2014-06-20
    • 2013-03-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-06-26
    相关资源
    最近更新 更多