Velocity ResourceTool 对象可以了解当前请求吗?
我对 ResourceTool.java
进行了子类化并覆盖了 get()
示例之一:
public class MySubClassedResourceTool extends ResourceTool {
@Override
public Object get(String arg0, String[] arg1, Locale arg2) {
Locale locale = //... get me here a locale from Request or Session object;
return super.get(arg0, arg1, locale);
}
}
我需要将 Locale
替换为 Locale
来自请求或会话的对象。
ResourceTool
是否可以访问或可以以任何方式直接访问客户端的 Request
或 Session
对象?
I sub-classed ResourceTool.java
and overrode one of the get()
example:
public class MySubClassedResourceTool extends ResourceTool {
@Override
public Object get(String arg0, String[] arg1, Locale arg2) {
Locale locale = //... get me here a locale from Request or Session object;
return super.get(arg0, arg1, locale);
}
}
I need to replace the Locale
with the Locale
object coming from the request or session.
Does ResourceTool
have access to or can it be made in any way to have direct access to client's Request
or Session
object?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
http://velocity.apache .org/tools/releases/2.0/javadoc/org/apache/velocity/tools/generic/ResourceTool.html
是的,只需将其放入请求范围内,它将具有(并使用)访问权限自动到请求的区域设置。
http://velocity.apache.org/tools/releases/2.0/javadoc/org/apache/velocity/tools/generic/ResourceTool.html
Yes, just put it in request scope and it will have (and use) access to the request's locale automatically.