【问题标题】:Referencing java.io.tmpdir inside web.xml file在 web.xml 文件中引用 java.io.tmpdir
【发布时间】:2013-09-17 20:01:48
【问题描述】:

例如,我如何将一些 servlet init-param 映射到 java.io.tmpdir/test 之类的东西?

我已经尝试过${java.io.tmpdir}/test,但没有成功。

谢谢

【问题讨论】:

  • 如果你在 web.xml 上使用 init 参数,你可以在 web.xml 中使用 ${initParam.myCustomPath}... 你会有这样的: myCustomPath/tmp/my-app/

标签: java servlets web.xml


【解决方案1】:

这不是 Servlet 内置的。您必须在代码中实现这一点。 Spring 库为此提供了一个类:http://docs.spring.io/spring/docs/3.2.x/javadoc-api/org/springframework/web/util/ServletContextPropertyUtils.html

我还看到人们重写 ServletContext 来提供这种支持: http://www.coderanch.com/t/484445/Servlets/java/access-System-Properties-determine-param

【讨论】:

    猜你喜欢
    • 2015-12-08
    • 1970-01-01
    • 2011-09-29
    • 1970-01-01
    • 2013-12-06
    • 2010-11-27
    • 1970-01-01
    • 2012-11-14
    • 1970-01-01
    相关资源
    最近更新 更多