2016-05-03 93 views
0

我想打印從函數返回的字符串值。JspWriter類型中的print(boolean)方法不適用於參數

但我得到的錯誤,即使是這個簡單的過程。

錯誤:

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> 

回答

0

在你的代碼: 16: <%=System.out.println(s)%>

這將是 16: <%=s %>

,因爲它被解釋爲<% out.print(s) %>

+0

我做it.Error org.apache.jasper.JasperException:發生異常在線處理JSP頁/beansal.jsp 16 13: 14: 15: 16:<(%)=新DBConnectionTest( ).Test()%> 17:   18: 19: –

+0

DBConnectionTest是否在任何包? – CrawlingKid

+0

Add ..'<%@ page import =「mypackage.DBConnectionTest」%>'。不屬於任何包的類,jsp有時無法找到它。 – CrawlingKid

相關問題