Using spring validation on request headers?

I don't see how this would be possible, since the validation framework only operates on your domain objects, not on the HTTP request itself. Specifically the Validator interface doesn't specify any methods that take the HttpServletRequest object, which is what you'd need to have access to in order to grab the headers and test them.

Up vote 0 down vote favorite 1 share g+ share fb share tw.

Thanks! Spring-mvc input-validation link|improve this question asked Oct 19 '09 at 17:48eqbridges1,3491511 84% accept rate.

I don't see how this would be possible, since the validation framework only operates on your domain objects, not on the HTTP request itself. Specifically, the Validator interface doesn't specify any methods that take the HttpServletRequest object, which is what you'd need to have access to in order to grab the headers and test them. Using the validation framework feels like the wrong solution to whatever problem you're trying to solve, especially since it's hard to know how there'd be a unique HTTP request header for a given form submission.

Are you looking to test for an HTTP header that should always be present in requests to your app? Then you might want to consider implementing a HandlerInterceptor, which will intercept and process all requests to pages that you've mapped in any HanderMappings. Are you looking to test for an HTTP header that should always be present in any page view of your app?

Then you'd want to implement a Filter, which operates outside of the context of Spring MVC.

We have a custom http client that submits an http header to identify itself. I think that handler interceptor is the way to go. Thanks!

– eqbridges Nov 19 '09 at 20:22.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions