博文

目前显示的是 七月, 2014的博文

Spring - Flash scope and Post-Redirect-Get pattern

What is flash scope? Flash scope is a concept which does not exist in Spring, but in JSF 2 and Play framework.  It is a scope between request scope, which is created and removed for each request, and session scope, which last for entire user session.  Flash scope is used in the Post-Redirect-Get pattern. Attributes kept in flash scope, using flash bean , will be available during the current request and the next request. What is  Post-Redirect-Get ? How to achieve flash scope in Spring? Since Spring 3.1+, RedirectAttributes  can be used for the same purpose. See  http://www.tikalk.com/java/redirectattributes-new-feature-spring-mvc-31

Spring bean config XML, Java config and more

1. XML-based metadata This is typical bean definition written in XML:     <bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">         <property name="dataSource" ref="dataSource"/>     </bean>    <jee:jndi-lookup id="dataSource" jndi-name="java:databaseName"/> Or     <bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">         <property name="dataSource" ref="dataSource"/>     </bean>     <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">         <property name="driverClassName" value="net.sourceforge.jtds.jdbc.Driver"/>         <property name="url" value="jdbc:jtds:sqlserver://host_name/database_name;schema=dbo"/>         <property name="username" value="dummy"/...

javax.servlet.jsp.el.ELException: Unable to find a value for "name" in object of class "java.lang.String" using operator "."

This is piece of jstl problem that is difficult to identify. A. When using <c:forEach> tag you sometimes get a error message like this: javax.servlet.jsp.el.ELException: Unable to find a value for "name" in object of class "java.lang.String" using operator "." Before knocking your head on the wall, check if there is trailing space(s) in the attribute like this one:  items="${orderList} _ " (I mark it as underscore so you easily see it.) And that's the problem! B. Suppose you have an inner class with default package access. Now you have a model attribute in your controller, which is having member of this inner class type, and in the jsp you find you can not refer to it using . operator with expression language. In such case you must declare the inner class as public. That's because even in your controller you can access the inner class, but the bean is not in "same package" when you access with jstl.