问题标签 [guice-servlet]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
entitymanager - 使用 guice-persist 自动清除会话
我正在使用一个在 tomcat 上运行 guice-servlet 并在 guice-persist 下休眠的环境。我遇到的问题是,当我在一个请求中使用 em.getReference() 时,加载的代理对象保留在 entitymanager 缓存中,并且可能出现在我希望从数据库中完全加载对象的另一个请求中。
我曾经在 EJB3 环境中使用休眠,这是默认行为。实体管理器缓存对于每个新请求都是清除的。guice-persist 为每个请求清除会话不是更安全的行为吗?或者至少将其作为 JpaPersistModule 的设置?
hibernate SessionImpl "autoClear" 中有一个特殊的标志,它负责 EJB3 行为。当 JpaPersistModule 创建新的实体管理器时,有什么方法可以启用该标志?
tomcat - 自定义动态错误 404 页面 - guice / tomcat
我正在 tomcat 7 服务器上使用 guice 3.0 创建一个 Web 应用程序。
我设法使用静态文件来自定义错误 404 页面,但现在我需要使用 servlet 自定义错误 404 页面。
因此,在我的 web.xml 中,我添加了这些行:
在我的模块配置中
如果我直接从浏览器访问 /error 页面,它就可以工作。但是如果我自愿要求一个不存在的页面,我有一个空白页面。浏览器已收到 404 状态但没有内容。此外,我已经向 servlet 添加了日志跟踪,而且似乎它甚至没有被调用。
在此先感谢您的帮助。
java - How to clear browser cache using java
I have a problem in sessions. When ever I logout the session is ended but then when the browsers back button is pressed I am getting the previous page. I am using jsp servlet technology and my code for logout is given below
can anybody tell me where is the problem and what will be the solution for this problem?
hibernate - Guice-Persist - “这个线程上的工作已经开始。看起来你已经调用了 UnitOfWork.begin() 两次,而在两者之间没有对 end() 进行平衡调用。”
我们的应用程序是一个广泛使用 Guice-Persist 和 Guice-Servlet 的 Java-GWT 应用程序。我们使用 Guice-Persist 的 session-per-HTTPRequest 功能从未遇到过问题,这与 Warp-persist 最初使用的功能相似。
根据文档,我们正在通过 PersistFilter 类过滤我们的 webapp。根据此处的 Guice 文档,我们的 persistence.xml 文件具有 transaction-type="RESOURCE_LOCAL" 。
现在由于某种奇怪的原因,我们的 PROD 环境显示错误
“这个线程上的工作已经开始。看起来你已经调用了 UnitOfWork.begin() 两次,而在两者之间没有对 end() 进行平衡调用。”
看起来 Guice-Persist 不支持嵌套工作单元的问题。关联
我们最近还从休眠 3.6.3.Final 迁移到了 4.1.4.Final。不确定他是否会与guice有某种不兼容...
在这一点上,我们完全不知道为什么会发生这种情况。
java - 有没有办法使用 jersey 和 guice 在 url 开头处理额外的斜杠?
我有一个 REST api,使用 jersey 和 guice 进行依赖注入。一切都很好,我打开了 FEATURE_CANONICALIZE_URI_PATH 和 FEATURE_NORMALIZE_URI 并且在几乎所有情况下都可以处理额外的斜杠。例如:
问题是我无法找出正确的方法来处理 url 开头的额外斜杠(在服务路径之前)。像这样:
这就是我目前设置东西的方式:
web.xml
MyServletConfig.java
我的服务.java
我可以看到问题实际上是在服务名称之前带有 // 的请求实际上并没有被 servlet 处理,因为它在过滤器映射的 url-mapping 中不匹配,但我只是不太确定正确的解决方案。在该 url 与 servlet 匹配之前,我是否需要进行 url 重写,或者是否有更好的方法来映射请求 url?
servlets - Guice、Peaberry 和 ServletModule
我在让 Peaberry/Guice/OSGi/Servlets 放置好时遇到问题。首先,我一直在将基于 Jetty、WAR 部署的 webapp 迁移到 OSGi 以利用插件架构。我原来的应用程序到处都在使用 guice。
我已将所有内容分解为模块并使用 Maven 进行构建。除了 ServletModule 的烦人安装之外,一切似乎都在工作。
当我尝试安装 ServletModule 时收到以下异常:
所以我不太清楚为什么找不到这些捆绑包。我已经添加了 guice-servlet 依赖项,并验证了它是否正在我部署的包中。
我想另一个重要的部分是注册 GuiceFilter。我使用 ServiceTracker 来获取 ExtHttpService,因为我使用的是 Jetty。当该 Tracker 返回时,我使用典型调用添加注册它
这似乎工作正常。我真的很难让这些东西正常工作,而且我有点夹在 Guice/OSGi/Peaberry 部分之间。任何帮助深表感谢。
谢谢!
java - Guice 和非单例 Servlet
我们如何在 Guice 中使用非单例 servlet 或处理程序,例如,我想为每个请求创建新实例并在处理请求后立即将其销毁或将其提供给垃圾收集器。
我不想将 ii 作为单例保存在内存中,也不想重用于其他未来的请求。
我认为可能以某种方式通过使用 bind() 函数,
RGDS
guice - 使用 guice servlet 设置 web.xml 侦听器和上下文参数
我正在使用 guice 和 guice servlet 开发一个 Web 项目。我已经设置了 guice 过滤器和监听器。
通过此设置,我可以使用 serve(...) 和 filter(...) 方法在 servlet 模块中模拟 web.xml 过滤器和 servlet。
现在的问题:
在 guice servlet 页面上,他们声称不再需要 web.xml,但我无法弄清楚如何:
注册上下文监听器(web.xml 中的监听器标签)和
添加上下文参数(我可以设置初始化参数)
这甚至可以使用 guice servlet 吗?
java - Light Java web stack using Guice-servlet/Jetty/Jersey - some questions
I'm thinking about developing a new web application using "light" components and not a full stack framework.
This article is my main inspiration!
Jetty : The web server. I'll probably use an embedabble version for development but with an option to export the application as a .war and use an external Jetty server for the production environment.
Guice/Guice-Servlet : For Dependency injection and for the servlet mapping + filters.
Jersey : For the routing + request/response json (de)serialization when required.
An important note : I'm aware some people will use this kind of stack with Jersey as a web services layer only, and will use a Javascript framework (Backbone, AngularJS, etc.) to consume those services and do most of the presentation logic in Javascript. I'm not ready yet for this kind of client stuff. I still prefere to use JSPs and been able to send plain HTML to clients that have javascript disabled.
So, my questions :
What is the best way to manage forms using Jersey? With Spring MVC (that I used on other projects) there is this concept of "backing objects" where the submitted POST data is automatically binded to a backing object that is then easy to play with. Is there something similar with Jersey?
I like all my routes to be defined in one specific routes file, not everywhere as @Path annotations which are, in my opinion, harder to manage. I'm pretty sure Jersey requires the use of those hardcoded JAX-RS's @Path annotations and doesn't allow an external routes configuration system, is that correct? Do you see any way I could centralize all routes with Jersey then?
I like the concept of reverse routing (like Play framework provides, for instance). And, again, I don't think Jersey can provide that functionality, is that correct?
Considering my previous questions, maybe Jersey is not the right technology to use? Do you know of others libraries I could use for the routing part in my stack?
Any other suggestions/tips for this kind of light Java web stack?
UPDATE :
I'm currently looking at UrlRewriteFilter for the routing part.
I'm also looking at the ActiveWeb framework, which is a "full stack" framework, but seems light and also seems to provide some functionalities I'm looking for : centralized routing config and reverse-routing.
guice - Guice:是否可以在给定特定父/接口/注释的情况下获取所有绑定实例?
我知道这可能不是最纯粹形式的依赖注入,但假设我必须使用:
使用这个注入器,是否可以获得所有给定的绑定实例:
- 每个实例将继承自一个父类?
- 每个实例将实现的接口?
- 每个实例都有一个注释?
我看到了Injector#findBindingsByType()方法,但我不确定它在这方面是否有帮助。