Hello all!
I need to use some file from my application in it, how can i do this?
I tried to do this with <mvc:resources> but it didn't work... Maybe i doing smth wrong, please help me.
My needed file is located in the src\main\webapp\META-INF\resources\file.xsl
In the code i try to get this file by:
But on the log:Code:ApplicationContext appContext = new ClassPathXmlApplicationContext("classpath:/WEB-INF/spring/root-context.xml"); Resource resource = appContext.getResource("classpath:/META-INF/resources/file.xsl");
getFileFromDb-servlet.xmlCode:java.io.FileNotFoundException: class path resource [META-INF/resources/file.xsl] cannot be opened because it does not exist at org.springframework.core.io.ClassPathResource.getInputStream(ClassPathResource.java:158)
root-context.xmlCode:<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xmlns:mvc="http://www.springframework.org/schema/mvc" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd"> <context:annotation-config /> <mvc:annotation-driven/> <!-- Handles HTTP GET requests for /resources/** by efficiently serving up static resources --> <mvc:resources location="/, classpath:/META-INF/resources/" mapping="/resources/**"/> <!-- Allows for mapping the DispatcherServlet to "/" by forwarding static resource requests to the container's default Servlet --> <mvc:default-servlet-handler/> </beans>
web.xmlCode:... <import resource="classpath:WEB-INF/getFileFromDb-servlet.xml" /> ...
.classpath contains this:Code:<servlet> <servlet-name>getFileFromDb</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>getFileFromDb</servlet-name> <url-pattern>/getFileFromDb/*</url-pattern> </servlet-mapping>
Code:<classpath> <classpathentry including="**/*.java" kind="src" output="target/test-classes" path="src/test/java"/> <classpathentry including="**/*.java" kind="src" path="src/main/java"/> <classpathentry excluding="**/*.java" kind="src" path="src/main/resources"/> <classpathentry excluding="**/*.java" kind="src" path="src/main/webapp/WEB-INF/resources"/> <classpathentry excluding="**/*.java" kind="src" path="src/main/webapp"/> ...
Thank you very much!


Reply With Quote