Java 如何在web.xml中设置资源的根路径
我的web.xml中有两个servlet映射,我想为下面的servlet引用的资源设置根路径。我的目标是不必将整个路径放在JSP中 示例:我不需要放置资源/admin/images的映像路径,而是希望能够放置/images 文件结构如下:Java 如何在web.xml中设置资源的根路径,java,apache,tomcat,spring-mvc,spring-security,Java,Apache,Tomcat,Spring Mvc,Spring Security,我的web.xml中有两个servlet映射,我想为下面的servlet引用的资源设置根路径。我的目标是不必将整个路径放在JSP中 示例:我不需要放置资源/admin/images的映像路径,而是希望能够放置/images 文件结构如下: |_ admin |_index.jsp |_resources |_images |_views |_dashboard.jsp (file in which I want t
|_ admin
|_index.jsp
|_resources
|_images
|_views
|_dashboard.jsp (file in which I want to use the scoped file paths)
我有一个根作用域,它是我的sitelocalhost.com的基础。我想有另一个作用域,它是我试图定义的localhost.com/admin级别的
我尝试了搜索,但不确定要向servlet映射添加什么。下面是我的web.xml
铬
铬
log4jConfigLocation
类路径:log4j.xml
上下文配置位置
类路径:applicationContext.xml
类路径:spring-security.xml
org.springframework.web.context.ContextLoaderListener
铬
org.springframework.web.servlet.DispatcherServlet
上下文配置位置
/WEB-INF/conf/spring-controllers.xml
1.
铬
/
httpMethodFilter
org.springframework.web.filter.hiddenhttmpmethodfilter
httpMethodFilter
铬
管理
/resources/admin/index.jsp
管理
/管理员/*
15
springSecurityFilterChain
org.springframework.web.filter.DelegatingFilterProxy
springSecurityFilterChain
/*
如果不想暴露完整的文件路径,请将jsp文件放在WEB-INF文件夹中。虽然不能直接访问WEB-INF文件夹中的文件,但可以将请求转发给它 前锋应该是这样的:
RequestDispatcher view = req.getRequestDispatcher("/WEB-INF/admin/index.jsp");
view.forward(req, resp);
你应该用更多的细节来改进你的问题。例如,第二个servlet映射在哪里?并添加java标记,这样更多的人会看到您的问题。@DiogoSantana我添加了整个web.xml。我的目标是不必将整个路径放在我的JSP中:哪个完整路径?什么意思?你的问题到底是什么?@DiogoSantana我补充了一些说明。你想这样做是因为管理员只能访问这些资源?