– Already taught Spring in more than 20 countries • Core-Spring, Spring MVC, Spring with JPA/Hibernate, Apache Tomcat… • Active blogger on blog.springsource.com Michael Isvy 3
SpringSource 2012 Many « new Emerging Products » at VMware: CloudFoundry, GemFire, RabbitMQ … 我 Spring 1.0 SpringSource created (originally called Interface21) … Spring 1.0??
extends Validator { public void validate(Object target, Errors errors) { if ((DiningForm)target) .merchantNumber.matches("[1-9][0-9]*") ) errors.rejectValue(“merchantNumber”, “numberExpected”); } } Not the preferred way anymore!
javax.validation.Valid; … @Controller public class UserController { @RequestMapping("/user") public String update(@Valid User user, BindingResult result) { if (result.hasErrors()) { return “rewards/edit”; } // continue on success... } } Controller
<td> <%=user.getLastName() %> </td> </tr> <tr> <td> ${user.firstName} </td> <td> ${user.lastName} </td> </tr> <tr> <td> <c:out value="${user.firstName}"/> </td> <td> <c:out value="${user.lastName}"/> </td> </tr> Not perfect: it is better to use taglibs No html escape: risk for cross site scripting Good! jsp file
Just use DataTables4J – http://datatables4j.github.com/docs/ Datatables in Spring MVC <dependency> <groupId>com.github.datatables4j</groupId> <artifactId>datatables4j-core-impl</artifactId> <version>0.7.0</version> </dependency> pom.xml
custom tags <html xmlns:custom="urn:jsptagdir:/WEB-INF/tags/html" …> … <custom:inputField name="firstName" label="Enter your first name:" /> <custom:inputField name=”lastName" label="Enter your last name:" /> </html> JSP file 1 line of code instead of 9!! No more JSP soup!
• It’s easy to integrate Spring MVC with jQuery – Consider using DataTables4J – hOp://datatables4j.github.com/docs/ – Bootstrap is cool! – JSP custom tags can make your life easier Conclusion 48