草庐IT

spring-asm

全部标签

java - 如何在 spring web 应用程序运行时获取 spring-web-mvc 中的 WebApplicationContext 和 DispatcherServlet 的实例

我想在controller类下的函数中获取WebApplicationContext的实例和DispatcherServlet的实例。 最佳答案 从Spring2.5开始,您可以使用@Autowired注释获取对WebApplicationContext的引用:@AutowiredWebApplicationContextapplicationContext;您还可以通过实现ApplicationContextAware来获取ApplicationContext的引用界面:publicclassYourControllerimple

java - Spring Bootstrap 和 Aspect 是如何实现的?

我尝试配置日志记录方面,但我不明白它是如何工作的。我有一个springwebmvc应用程序。考虑一下:带有LoggingConfiguration的配置类包:importorg.springframework.context.annotation.Bean;importorg.springframework.context.annotation.Configuration;importorg.springframework.context.annotation.EnableAspectJAutoProxy;importmy.package.aspects.LoggingAspect;i

java - 如何使 Spring Joda-Time 格式化程序在非标准语言环境下工作?

我正在使用Spring3.1和Joda-Time开发多语言应用程序.假设我有一个这样的命令对象:privateclassMyCommand{privateLocalDatedate;}当我使用英国或美国语言环境请求时,它可以使用相应的日期格式正确解析并绑定(bind)date而没有任何问题,例如分别为2013年10月21日和2013年10月21日。但是,如果我有一些像georgiannewLocale("ka")这样的语言环境,它不会绑定(bind)有效日期21.10.2014。所以我需要连接到Spring格式化程序,以便能够为每个语言环境提供我自己的格式。我有一个可以从语​​言环境解

java - REST 服务未在 Apache wink 中注册到 Spring 和 Maven

我有一个Maven项目,其依赖项如下:wink.version=1.1.3-incubating和spring.version=3.0.5.RELEASESpring中的应用上下文包括:web.xml包括:contextConfigLocationclasspath:META-INF/wink/wink-core-context.xmlclasspath:applicationContext.xmlorg.springframework.web.context.ContextLoaderListenerrestServletorg.apache.wink.server.internal

java - 使用 sockjs 踩在套接字上无法连接 Spring 4 WebSocket

尝试使用Spring4WebSocket和STOMPoversocketusingsockjs。我遇到了一个问题。我的配置:websocket.xml-spring上下文的一部分Controller代码:@MessageMapping("/ws")@SendTo("/topic/ws")publicAjaxResponsehello()throwsException{AjaxResponseajaxResponse=newAjaxResponse();ajaxResponse.setSuccess(true);ajaxResponse.addSuccessMessage("WEBSOC

java - Spring:如何替换在Application Context中创建的Environment bean

我希望用我自己的实现替换Spring使用的环境bean。这是不好的做法吗?如果不是,我怎样才能干净地做到这一点?目前我已经创建了一个实现Environment接口(interface)并使用现有Environmentbean的bean,但这意味着所有需要Environmentbean的配置代码现在都必须使用我的自定义Environmentbean。我认为用我自己的替换SpringsEnvironmentbean会更干净,然后不需要更改需要它的配置。目前我能想到的唯一方法是创建我自己的ApplicationContext从而将环境设置为我自己的,或者让某些东西成为ApplicationC

java - 具有 stomp 安全性的 Spring websocket - 每个用户都可以订阅任何其他用户队列?

我创建了一个使用spring4的websockets机制的简单应用程序。我在我的应用程序中使用了一个activemq代理。在我的简单测试中,我为名为“Alejando”的用户创建了10条消息(user/alejandro/queue/greetings)当我使用“Alejando”登录并订阅该队列时:stompClient.subscribe('/user/alejandro/queue/greetings',function(greeting){showGreeting(JSON.parse(greeting.body).content);});我确实收到了为alejandro查询的

java - 使用自定义模式定义的 Spring Ldap 单元测试

我正在尝试为使用SpringLdap的单元测试设置嵌入式ldap。但我需要为自定义对象类/属性定义使用自定义模式。我如何使用SpringLdap测试(LdapTestUtils?)配置它实际上,如果我运行测试,它会失败并显示我的自定义对象类“myOb”未在架构中定义,并显示以下消息:org.springframework.ldap.UncategorizedLdapException:FailedtopopulateLDIF;nestedexceptionisjavax.naming.directory.NoSuchAttributeException:[LDAP:errorcode1

java - Spring Boot CommandLineRunner 异常处理

我们将Spring-boot用于命令行应用程序。我们使用javax.validation来验证命令行参数。现在,如果我们遇到验证错误,我们如何打印友好的错误消息?我们不想显示堆栈跟踪。当我们将Spring-boot作为CommandLineRunner运行时,是否有我们可以使用的ExceptionHandler机制?谢谢阿伦来源@SpringBootApplicationpublicclassDeployimplementsCommandLineRunner{privatestaticfinalLoggerLOGGER=LoggerFactory.getLogger(Deploy.cl

java - 使用 Spring MVC 和 Spring Security 的登录表单中的 CSRF token 为空

${_csrf.parameterName}和${_csrf.token}在登录表单中变空。我正在使用Spring4.1.3和SpringSecurity3.2.5所有的配置都正确,但我还是得到了作为 最佳答案 我找到了答案,我将web.xml中的安全过滤器标记放在所有其他过滤器的顶部并且它起作用了。 关于java-使用SpringMVC和SpringSecurity的登录表单中的CSRFtoken为空,我们在StackOverflow上找到一个类似的问题: