简体   繁体   中英

JSP import Java class

When I try to call the method after importing the class, like below, I get method is undefined error.

<%@page import="td.TourHelper"%>
<%=getTourName()%>

But, when I directly call the method, it works.

<%=td.TourHelper.getTourName()%>

Any clues?

Change

<%=getTourName()%>

to

<%=TourHelper.getTourName()%>

The first option will work if your container supports static imports provided you change the page directive as below

<%@page import="static td.TourHelper"%>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM