1

以下是我的jsp代码。我是 JSP 的新手。我收到代码后显示的错误

<body>
<%!
    public ArrayList<ArrayList<Leg>> trip;
    public void routeManager(){
        Location stLoc = new Location(60.2040521,24.96185113,"1023");
        Location endLoc = new Location(60.17936316, 24.92282214 ,"1130");
        RouteRetriever hrr = new RouteRetriever();
        trip = hrr.getRoutes(stLoc, endLoc, false);
    }
%>
<%  routeManager();
    System.out.println("Im here AA");%>
<%= out.println("Hello World:"+hrr.size()) %>
<p>Booooooooooooo!</p>
</body>

错误:

An error occurred at line: 30 in the jsp file: /index.jsp
The method print(boolean) in the type JspWriter is not applicable for the arguments (void)
4

2 回答 2

2

我觉得你应该改变

<%= out.println("Hello World:"+hrr.size()) %>

到(只是输出)

<%= "Hello World:"+trip.size() %>

或者如果您想使用 println(将 <%= 更改为 <%):

<% out.println("Hello World:"+hrr.size()); %>
于 2012-05-10T08:45:07.317 回答
0

<%=%>并且out.println不一起去。

改变

<% out.println("Hello World:"+hrr.size()); %>

<%=%>out.write是Jsp页面编译时转换成的简写

于 2012-05-10T09:18:53.433 回答