Tag: spring mvc

在Spring的Session Expiry之前执行自定义事件

我是Spring框架的初学者。 在我的情况下,会话可以通过以下方式到期 – >成功注销(显式注销) – >会话超时(隐式注销) 无论何时某个用户登录,我都在数据库中进行DML(记录插入),并且每当用户会话超时(隐式注销)时我想在数据库中执行DML(记录删除)。 我的问题是spring有没有办法在会议结束前告诉我们。 所以我可以在会话到期之前执行我的自定义事件。 提前致谢

Spring – 应用程序初始化两次?

当我开始运行我的Spring应用程序我的tomcat时, ContextRefreshedEvent会触发两次。 请参阅StackTrace。 Dec 20, 2013 6:07:56 PM org.apache.tomcat.util.digester.SetPropertiesRule begin WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property ‘source’ to ‘org.eclipse.jst.j2ee.server:SpringValidations’ did not find a matching property. Dec 20, 2013 6:07:56 PM org.apache.catalina.core.AprLifecycleListener init INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Program Files\Java\jre6\bin;.;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;C:/Program Files/Java/jre6/bin/client;C:/Program Files/Java/jre6/bin;C:/Program […]

在Spring MVCvalidation中,是否可以一次只显示每个字段一条错误消息?

例, 我有 @NotEmpty //tells you ‘may not be empty’ if the field is empty @Length(min = 2, max = 35) //tells you ‘length must be between 2 and 35′ if the field is less than 2 or greater than 35 private String firstName; 然后我输入一个空值。 它说”可能不是空的长度必须在2到35之间’ 是否有可能告诉spring每个字段一次validation一个?

Action类可以限定为Singleton吗?

我的问题不仅仅是动作类可以限定为单例,而且我还想知道哪些是最佳实践。 两者都在Struts2和Spring的背景下。 控制器和型号的最佳VIEW范围(例如请求或会话)。

Spring SimpleFormController 3.0

我注意到这个控制器现在已经在最近的spring被弃用了,并且想知道替代控制器是什么?

找不到默认构造函数; 嵌套exception是使用Spring MVC的java.lang.NoSuchMethodException?

我正在使用Spring MVC控制器项目。 下面是我的控制器,我有一个声明的构造函数,我专门用于测试目的。 @Controller public class TestController { private static KeeperClient testClient = null; static { // some code here } /** * Added specifically for unit testing purpose. * * @param testClient */ public TestController(KeeperClient testClient) { TestController.testClient = testClient; } // some method here } 每当我启动服务器时,我都会遇到exception – No default constructor found; nested exception […]

无法在MessageSource中找到消息

我试图让一个简单的spring应用程序运行,但得到以下exception: javax.servlet.ServletException:javax.servlet.jsp.JspTagException:在代码’label.firstname’下找不到区域设置’en_US’的消息。 我的contact.jsp文件: Spring 3 MVC Series – Contact Manager | viralpatel.net Contact Manager <input type="submit" value="”/> Contacts Name Email Telephone   ${contact.lastname}, ${contact.firstname} ${contact.email} ${contact.telephone} delete 我的spring-servlet.xml文件 <!– classpath:hibernate.cfg.xml org.hibernate.cfg.AnnotationConfiguration ${jdbc.dialect} true 我正在打url: 本地主机:8080 / MavenWeb-0.0.1 /索引 和我的服务器堆栈跟踪: SEVERE: No message found under code ‘label.firstname’ for locale ‘en_US’. javax.servlet.jsp.JspTagException: No message found under code […]

如何将Spring MVC控制器映射到带有和不带斜杠的uri?

我有一个Spring Controller,它有几个RequestMappings用于不同的URI。 我的servlet是“ui”。 servlet的基URI仅适用于尾部斜杠。 我希望我的用户不必输入尾部斜杠。 这个URI有效: http://localhost/myapp/ui/ 这个没有: http://localhost/myapp/ui 它给了我一个HTTP状态404消息。 我的web.xml中的servlet和映射是: ui org.springframework.web.servlet.DispatcherServlet 1 ui /ui/* 我的控制器: @Controller public class UiRootController { @RequestMapping(value={“”,”/”}) public ModelAndView mainPage() { DataModel model = initModel(); model.setView(“intro”); return new ModelAndView(“main”, “model”, model); } @RequestMapping(value={“/other”}) public ModelAndView otherPage() { DataModel model = initModel(); model.setView(“otherPage”); return new ModelAndView(“other”, “model”, model); } }

Spring @RequestBody包含不同类型的列表(但是相同的接口)

假设我有一个域类: public class Zoo{ private List animals; …. 其中Animal是具有不同实现的接口(Cat,Dog)。 假设我希望能够保存Zoo对象: @RequestMapping(value = “/zoo”, method = RequestMethod.POST) public @ResponseBody void save(@RequestBody Zoo zoo) { …. 我想发送一个json – 类似于: { animals:[ {type:’Cat’, whiskers-length:’3′}, {type:’Dog’, name:’Fancy’} ] } 当键入==’Cat’时,如何告诉spring MVC将动物映射到Cat类型,并在键入==’Dog’时将其映射到Dog类?

如何在JSTL中正确拆分字符串?

如何使用JSTL在jsp页面内拆分用“/”分隔的字符串? 我有一个这种格式的字符串:** “23/11/2010” * 。 有时,字符串可能是这样的:* “1/1/2010” * 。 我需要做一些事情,以便将字符串分成三个不同的子串:* “23”,“11”,“2010”。 **这是因为我需要将它们中的每一个放在三个不同的文本字段中,如下所示: / / 我还找不到任何有用的例子。 提前致谢!