草庐IT

guice-servlet

全部标签

java - 任何人都可以清楚地解释为什么 Google Guice 有用吗?

我已经阅读了有关GoogleGuice的信息,并且了解其他依赖注入(inject)方法的一般问题,但是我还没有看到有人在“实践”中使用Guice的例子,它的值(value)变得清晰。我想知道是否有人知道任何此类示例? 最佳答案 使用GoogleGuice简化单元测试只是高级别的优势。有些人甚至可能不会在他们的项目中使用单元测试。人们一直在使用Spring/DependencyInjection,而不仅仅是用于单元测试。使用GoogleGuice的低级优势在于应用程序的内聚性,项目中的类之间可以松散耦合。我可以为另一个类提供一个类,而

java - Servlet 过滤器 : How to get all the headers from servletRequest?

这是我的WebFilter的样子@WebFilter("/rest/*")publicclassAuthTokenValidatorFilterimplementsFilter{@Overridepublicvoidinit(finalFilterConfigfilterConfig)throwsServletException{}@OverridepublicvoiddoFilter(finalServletRequestservletRequest,finalServletResponseservletResponse,finalFilterChainfilterChain)thr

java - Servlet 过滤器 : How to get all the headers from servletRequest?

这是我的WebFilter的样子@WebFilter("/rest/*")publicclassAuthTokenValidatorFilterimplementsFilter{@Overridepublicvoidinit(finalFilterConfigfilterConfig)throwsServletException{}@OverridepublicvoiddoFilter(finalServletRequestservletRequest,finalServletResponseservletResponse,finalFilterChainfilterChain)thr

java - 在运行 Spring MVC 应用程序时在 Spring Boot 中获取 NoSuchMethodError : javax. servlet.ServletContext.addServlet

当我尝试使用SpringBoot运行SpringMVC应用程序时遇到异常...ContainerBase:Achildcontainerfailedduringstartjava.util.concurrent.ExecutionException:org.apache.catalina.LifecycleException:Failedtostartcomponent[StandardEngine[Tomcat].StandardHost[localhost].StandardContext[]]atjava.util.concurrent.FutureTask.report(Fut

java - 在运行 Spring MVC 应用程序时在 Spring Boot 中获取 NoSuchMethodError : javax. servlet.ServletContext.addServlet

当我尝试使用SpringBoot运行SpringMVC应用程序时遇到异常...ContainerBase:Achildcontainerfailedduringstartjava.util.concurrent.ExecutionException:org.apache.catalina.LifecycleException:Failedtostartcomponent[StandardEngine[Tomcat].StandardHost[localhost].StandardContext[]]atjava.util.concurrent.FutureTask.report(Fut

已解决异常:Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception

已解决异常:Servlet.service()forservlet[dispatcherServlet]incontextwithpath[]threwexception本文目录一、Bug描述二、定位报错点及原因三、最终的解决方案方案1:编译出错方案2:Controllor层引入的Service接口上面忘记写@Resource或@Autowired注解方案3:Controllor层调用的方法是private私有的,导致分发失败方案4:SpringBoot注解没有正确使用四、相关注意事项总结一、Bug描述今天开发的时候,遇到了这个bug:“dispatcherServlet”的异常问题。详细报错

java - Guice 和属性文件

有没有人举例说明如何使用GoogleGuice从.properties文件中注入(inject)属性。有人告诉我,Guice能够在注入(inject)器启动时验证所有需要的属性是否存在。目前我在guicewiki上找不到任何关于此的内容。 最佳答案 您可以使用Names.bindProperties(binder(),getProperties())绑定(bind)属性,其中getProperties返回Properties对象或Map(将属性文件作为Properties对象读取由您决定)。然后您可以使用@Named按名称注入(in

java - Guice 和属性文件

有没有人举例说明如何使用GoogleGuice从.properties文件中注入(inject)属性。有人告诉我,Guice能够在注入(inject)器启动时验证所有需要的属性是否存在。目前我在guicewiki上找不到任何关于此的内容。 最佳答案 您可以使用Names.bindProperties(binder(),getProperties())绑定(bind)属性,其中getProperties返回Properties对象或Map(将属性文件作为Properties对象读取由您决定)。然后您可以使用@Named按名称注入(in

java - web.xml中url-pattern有什么意义,servlet如何配置?

我已经为我的应用程序手动配置了web.xml。现在,我在运行我的应用程序时遇到了问题。我正在尝试从我的jsp页面访问我的servlet。但是,它会抛出错误,因为pagenotfound.servlet位于以下文件夹位置/WEB-INF/classes/那么,url-pattern和servlet-mapping中的servlet条目应该是什么。这样,servlet就可以通过URL访问了。 最佳答案 url-pattern在web.xml中用于将您的servlet映射到特定的URL。请参阅下面的xml代码,您可以在web.xml配置文

java - web.xml中url-pattern有什么意义,servlet如何配置?

我已经为我的应用程序手动配置了web.xml。现在,我在运行我的应用程序时遇到了问题。我正在尝试从我的jsp页面访问我的servlet。但是,它会抛出错误,因为pagenotfound.servlet位于以下文件夹位置/WEB-INF/classes/那么,url-pattern和servlet-mapping中的servlet条目应该是什么。这样,servlet就可以通过URL访问了。 最佳答案 url-pattern在web.xml中用于将您的servlet映射到特定的URL。请参阅下面的xml代码,您可以在web.xml配置文