spring-mvc

(Spring MVC)-like framework in python

Do you know a framework in Python which is similar to the Spring MVC java framework? What I'd love to have is that magic Converters that get, say, a movie_id from the request url and automatically fetch the Movie from you database and call a method of yours passing the object. If you have used Spring MVC you might understand what I mea...

Best way to include sub-templates into templates in Spring MVC

I'm writing webapp using Spring 3 MVC with annotations. I use jsp for view layer. I have a few basic templates and many templates that I want to include into this basic templates in depend of controller. I know that I can add template name to model inside controller, but it is not best way I think. I think some declarative way must exis...

SpringMVC form bind to command object which is interface

I'm learning SpringMVC 2 and i have a form that i need to bind to an object (the command). But what if i need this command object to be an interface so i can use different implementations for the object (of course all the implementations will have the same fields). For binding a form that represents an Account i have this controller. Is...

XStreamMarshaller autodetect annotations -- Cannot flush HierarchicalStreamWriter

My context looks like this: <bean id="xStreamMarshaller" class="org.springframework.oxm.xstream.XStreamMarshaller" p:converters-ref="converters" p:autodetectAnnotations="true"/> And if I switch on annotation auto-detection I get org.springframework.oxm.xstream.XStreamMarshaller - Could not flush HierarchicalStreamW...

spring 3 RequestMapping get path value

Is there a way to get the complete path value after the requestMapping pathvariable values has been parsed. That is: /{id}/{restOfTheUrl} should be able to parse /1/dir1/dir2/file.html id=1 and restOfTheUrl=/dir1/dir2/file.html Any ideas would be appreciated. ...

Using RestTemplate, how to send the request to a proxy first so I can use my junits with JMeter?

I have a web service running on my dev box implemented using Spring-MVC 3.0. I have various JUnits that test against that service using RestTemplate. What I would like to do is have JMeter pick up those JUnits REST requests when I run them. However, to do that, I need to have Spring's RestTemplate send them to the proxy that I'm running ...

applying JSP/JSTL's <c:url> to a path inside a servlet

In our JSP pages, we use extensively. Works great, rewrites the URL to deal with sessionids, contexts, etc. But now we need to do some of this work inside a class that takes an HttpServletRequest and HttpServletResponse as part of the Spring Security specification. How do I apply a type transformation to a path in a servlet? I gues...

Spring2 web MVC - dynamic views for controller ?

Is there a way in Spring2 to build dynamic views to which a Controller can redirect to? I have a form with a hidden field for an ID. If the form is submited or other exception occurs i want to redirect back to the form (i have set formView). It redirect ok, but when it redirect back to form it is loosing the ID parameter. Is there a way...

Approach for validating 1 of n fields must be valid?

What's the preferred approach for validating that at least one of fieldA, fieldB, or fieldC is valid using a Spring 3 validator? In other words, any 2 of the fields can be invalid, as long as the third is not. ...

Howto get rid of <mvc:annotation-driven />?

Up to now, <mvc:annotation-driven /> has caused plenty of trouble for me, so I would like to get rid of it. Although the spring framework docs clearly say what it is supposed to be doing, a listing of tags actually summar <mvc:annotation-driven /> is lacking. So I'm stuck with removing <mvc:annotation-driven /> and now getting the erro...

How can you print out the values of undeclared HTML form values from a Spring (3) controller action method?

If my HTML form contains two form inputs (input1 and input2), I could access them like this: @RequestMapping(value = "/foo", method = RequestMethod.POST) public String foo(HttpServletRequest request, ModelMap modelMap, @RequestParam(value = "input1") String input1, @RequestParam(value = "input2") String input2) { log...

Springs Simple <remember-me/> not working :-(

I am trying to make use of Spring Security's <remember-me/> authentification. The line in my security context looks like this: <security:remember-me key="89dqj219dn910lsAc12" user-service-ref="jpaUserDetailsService"/> Although I use my own implementation of UserDetailsService (tested & working), I have also tried with the default one...

Choosing an appropriate url pattern for Sitemesh to exclude my servlet from its decorators?

I configured my Spring web app with a servlet to serve images at the URL: /imgsrv?imgid=12345 I also have Sitemesh installed and now when I call this image servlet, I get a decorator exception related to this servlet, which does not need a decorator applied to it. According to the Sitemesh docs, you can exclude certain URLs from havi...

Set properties of bean inside form from jsp in Spring MVC

I have Bean A{ B b;} which encapsulates instance of Bean B. I have property name which i want to set name property of Bean B. Is there any way i can do it Spring. Currently i am using AbstractCommandController. ...

Spring MVC: Adding JAXB to the classpath so that it automatically serializes XML

According to Spring MVC documentation, <mvc:annotation-driven/> configures support for JSON if Jackson is in the classpath, and support for XML if JAXB is present in the classpath. Simply by adding a Jackson dependency to my pom.xml, I get JSON support to work! (see: Ajax Simplification in Spring 3.0) However, after trying to access the...

Spring MVC - Binding a Date Field

For request parameters representing string, number, and boolean values, the Spring MVC container can bind them to typed properties out of the box. How do you have the Spring MVC container bind a request parameter representing a Date? Speaking of which, how does the Spring MVC determine the type of a given request parameter? Thanks! ...

No Hibernate Session bound to thread

I am using Spring MVC and Hibernate. I want to use the OpenSessionInViewFilter to allow lazy loading to work properly in the view layer. The OpenSessionInViewFilter requires a root application context so i added a ContextLoaderListener and moved my non view related configuration files to it from the DispatcherServlet. The app-config.x...

Determine secure url in JSP with spring security

Like many websites, I have a login popup on every webpage of my site. Most of these pages are http (non-secure). But the login mechanism has to post to a secure url. All this works great. The problem is the secure url changes in the various dev environments, staging and different production environments. So not too big of a deal, I ...

Does Spring (3) have any built in support for pagination?

I have a model I need to paginate (Book listings - as explained in a previous question.). This seems like a common enough feature that I would expect some pre-built solutions for it without having to build a custom solution. Does Spring (3) have support for pagination? ...

How to make Spring MVC Controller error out if given a query param that is not valid or with a different case?

Title pretty much says it all. One of the requirements of a web service I'm working on is that if a query param name is given that is either invalid or not case-exact with what's expected, it should give an error saying so. Is there anything in Spring MVC that can do this via configuration or some kind of setting? I imagine it's possib...