Access resource file from JSP
问题 I want to access xml files from java class, lying under web/resources folder.. i.e ---Web pages | |--Web-INF | |-resources | |-data.xml | |-other jsps ---Source Folder |-databean I want to access data.xml from a class under databean package. Is it possible? How? 回答1: Use ServletContext#getResource() or #getResourceAsStream() to obtain resources which are available in the webcontent. InputStream input = getServletContext().getResourceAsStream("/WEB-INF/resources/data.xml"); You however