spring-mvc

What are the best books for Spring and Spring MVC?

My team is about to build a new product and we are using Spring and Spring MVC. There are other book posts on stackoverflow, but I couldn't find one that matched my needs. My manager will be purchasing books for our team to use as a resource so... What are the best books about Spring? (Please list each book suggestion in a separate an...

Annotated Spring-MVC controller not recognized when controller extends interface

I'm using spring 2.5, and am using annotations to configure my controllers. My controller works fine if I do not implement any additional interfaces, but the spring container doesn't recognize the controller/request mapping when I add interface implementations. I can't figure out why adding an interface implementation messes up the con...

Spring-MVC Problem using @Controller on controller implementing an interface

I'm using spring 2.5 and annotations to configure my spring-mvc web context. Unfortunately, I am unable to get the following to work. I'm not sure if this is a bug (seems like it) or if there is a basic misunderstanding on how the annotations and interface implementation subclassing works. For example, @Controller @RequestMapping("ur...

Spring MVC : Binding 3 dropdowns to a date property in SimpleFormController

How should I configure the class to bind three dropdowns (date, month, year) to a single Date property so that it works the way it works for 'single request parameter per property' scenario ? I guess a should add some custom PropertyEditors by overriding initBinder method. What else ? ...

How best to modify my model in Spring MVC if I care about IOC

I am building an application using Spring MVC. I want to make certain changes to my Model for every Controller in the application. In particular, I want to insert certain extra data into the model which will be present for all pages of the application. I could do this several ways: just add the data at the end of every Controller, use a...

Please share your experiences of DWR 3.0 M1 RC2 ?

Hi, I am planning to use DWR 3.0 M1 RC2 release candidate for my application. The primary reason of using this version is that it nicely integrates with Spring 2.5 framework and requires least possible level of configuration ! If you have using particularly this version of DWR, I would appreciate if you can share your experiences (bene...

Can anyone explain servlet mapping?

I'm trying to write a web application using SpringMVC. Normally I'd just map some made-up file extension to Spring's front controller and live happily, but this time I'm going for REST-like URLs, with no file-name extensions. Mapping everything under my context path to the front controller (let's call it "app") means I should take care ...

Adding HTTP Headers in a Spring Interceptor postHandle method

I have a Spring Interceptor which attempts to add an HTTP header in the postHandle() method. public void postHandle(HttpServletRequest req, HttpServletResponse resp, Object obj1, ModelAndView mv) throws Exception { response.setHeader("SomeHeaderSet", "set"); response.addHeader("SomeHeaderAdd", "added"); } } Howeve...

Unit tests vs integration tests with Spring

I'm working on a Spring MVC project, and I have unit tests for all of the various components in the source tree. For example, if I have a controller HomeController, which needs to have a LoginService injected into it, then in my unit test HomeControllerTest I simply instantiate the object as normal (outside of Spring) and inject the pro...

How do I bind collection attributes to a form in Spring MVC

I'm trying to bind one of my model objects to the fields of a form, using Spring-MVC. Everything works fine, except that one of the attributes of the model object is an unordered collection. Doing something like <c:forEach items="${m.items}" var="i" varStatus="itemsRow"> <form:input path="items[${itemsRow.index}]"/> </c:fo...

What are some use cases for various DispatcherServlet.detectAllXxx flags?

In Spring Web MVC, the DispatcherServlet has a bunch of flags, such as detectAllHandlerMappings detectAllHandlerAdapters detectAllHandlerExceptionResolvers detectAllViewResolvers that allow you to choose between finding all type-matched beans on the app context and finding at most one, matched under a specific ID. They all default to t...

Struts or Spring MVC or Struts & Spring?

I need some information to understand design decision: Is Struts a better choice than Spring MVC? I hear about Strus-Spring-Hibernae combo - Is struts used at MVC layer because its a matured framework than when compared to Spring MVC? Any one used this combination for projects or aware of issues? ...

What are best practices for preventing stale CSS and JavaScript

I'm researching this for a project and I'm wondering what other people are doing to prevent stale CSS and JavaScript files from being served with each new release. I don't want to append a timestamp or something similar which may prevent caching on every request. I'm working with the Spring 2.5 MVC framework and I'm already using the g...

How to reuse a Criteria object with hibernate?

I'm trying to do query result pagination with hibernate and displaytag, and Hibernate DetachedCriteria objects are doing their best to stand in the way. Let me explain... The easiest way to do pagination with displaytag seems to be implementing the PaginatedList interface that has, among others, the following methods: /* Gets the total...

Best Practice for Spring MVC form-backing object tree initialization

If I have a form-backing object that has a complicated object tree -- say a Person that has a Contact Info object that has an Address object that has a bunch of Strings -- it seems that the object needs to be fully populated with component objects before I can bind to it. So if I'm creating a new Person, I need to make sure it has all t...

Benefits of using JSTL vs Velocity for view layer in MVC app?

I'm currently building a Spring MVC application. I was looking to use JSP pages with tag libraries for handling the view layer and formatting of the HTML, but I've come across another group in my company that uses Velocity templates for the same purpose. From what I can see, it seems to me as if there are a lot of similarities between t...

How does Spring 2.5 map the incoming request data to ModelAttribute command ?

Hi, I have used Spring 2.0 and now I am using Spring 2.5 Natually, Spring 2.5 made life very easy as far as the Web Controllers are concerned. The question keeps coming in my mind that in 2.0 we had to set the command class and accordingly the AbstractFormController used to populate that command object for us. In Spring 2.5 we don't do ...

Spring MVC tag interaction with custom tag

I have a JSP that is using Spring:form tags to bind controls to a command object. I would like to modify it as follows: if [some condition is true] than display the controls; otherwise, just display the text. (Examples: if the user is an Admin, display the controls, otherwise just display the text. If the whatsit is still open for modi...

How can I determine what roles are required to access a URL with Spring Security?

I'm using Spring Security to secure a webapp. The URLs are secured like this: <security:http entry-point-ref="authenticationEntryPoint"> <security:intercept-url pattern="/" access="ROLE_ANONYMOUS" /> <security:intercept-url pattern="/assets/**/*" access="ROLE_ANONYMOUS" /> ... <security:intercept-url pattern="/**" access="ROLE_U...

Spring MVC validation with Annotations

I'm having quite some trouble since I migrated my controllers from classical inheritance to use the annotations like @Controller and @RequestMapping. The problem is that I don't know how to plug in validation like in the old case. Are there any good tutorials about this? ...