spring-mvc

How can I map a spring controller to a url with .jsp extension?

Hi. We are in the process of migrating a jsp-only application to Spring-MVC. For various reasons we can't change the extension of the current pages. (calls to login.jsp need to handled by a spring controller that will use a jsp file as view). We are doing this iteratively, so some pages need to stay jsp files (calls to welcome.jsp won'...

spring add default value to form:select

I'm developing a spring application, now I've added a dropdownlist to one of my jsp pages using: <form:select multiple="single" path="users[y.count-1].X" items="${Y}" itemValue="id" itemLabel="name"/> Now I'd like to add the default value "Nothing selected", however I can't seem to find how to do this. I've tried: <form:select multip...

Spring @RequestMapping and trailing slash problem

I am trying to map a method in a Controller using the annotation with URI template: @RequestMapping(value="/select/{customerNumber}/{resource}", method=RequestMethod.GET) It appears that this does not get mapped if there is a trailing slash at the end of "resource". Update: Using Spring 3.0.2 release Update: @RequesMapping seems to ...

Spring-JSON Used in Spring MVC

Hi, I came across the library Spring-JSON while looking to add Ajax Support in my spring mvc webapp 2.5. My question is, has anybody here have used this library and what are your experiences? Is there any better alternative than this? ...

spring-mvc binding arraylist in form

In my controller I added an ArrayList to my model with the attribute name "users". Now I looked around and this is the method I found (including a question here): <form:form action="../user/edit" method="post" modelAttribute="users"> <table> <c:forEach var="user" items="${users}" varStatus="counter"> ...

Spring transaction management breaks hibernate cascade

I'm having a problem where the addition of spring's transaction management to an application causes Hibernate to throw the following error: org.hibernate.HibernateException: A collection with cascade="all-delete-orphan" was no longer referenced by the owning entity instance: org.fstrf.masterpk.domain.ReportCriteriaBean.treatmentArms org...

Spring 3 and a custom object wrapper for FreeMarker

How do you configure Spring 3 to use a custom object wrapper to use with FreeMarker? I've created a custom object wrapper for FreeMarker but I'm not sure how you configure Spring 3 to use the wrapper. The following has no effect: <bean id="freemarkerConfig" class="org.springframework.web.servlet.view.freemarker.FreeMarker...

Get invalid user input with a Spring typeMismatch error

I've implemented a ReloadableResourceBundleMessageSource in my Spring MVC application which I use to display prettier error messages for binding exceptions. The problem I'm having is that, due to a company policy, these errors must be displayed in the following format: [inputData] is not a valid [fieldName]. The field name is accessibl...

Hibernate: update on parent-child relationship causes duplicate children

I have a parent child relationship in which the parent has a collection of children (a set to be specific). The child collection is setup with cascade="all-delete-orphan". When I initially save the parent element everything works as expected. However, when I update the parent and save again, all the children are re-saved. This behavior ...

Spring custom error message

I want to set a custom error message via @Controller, there is something like Struts saveMessages(...) in spring? for example: ActionErrors actionErrors = new ActionErrors(); actionErrors.add("error", new ActionMessage("error.missing.key", messageResources.getMessage("label.username"), messageResources.getMessage("label.password...

What are annotations and how do they actually work for frameworks like Spring?

I am new to Spring and now a days I hear a lot about Spring Framework. I have two sets of very specific questions: Set No. 1: What are annotations in general ? How does annotations works specifically with Spring framework ? Can annotations be used outside Spring Framework or are they Framework specific ? Set No. 2: What module o...

Spring MVC - @Controller annotation and processing concurent requests

I am using pieces of the Spring MVC framework; in particular, I am making use of the @Controller, @RequestMapping and @ResponseBody annotations, in conjunction with a webstatsHttpMessageConverter hooked up to an OXM jaxb2 marshaller bean. My controller methods use the @RequestParam annotations to parse some GET parameters, query a servic...

Store Business Rules in XML Document, Validate afterwards in Java, how?

Example XML Rules document: <user> <username> <not-null/> <capitals value="false"/> <max-length value="15"/> </username> <email> <not-null/> <isEmail/> <max-length value="40"/> </email> </user> How do I implement this? I'm starting from scratch, what I currently have is a User-class, and a UserCon...

Handling ajax requests with spring

Here is my problem, I need to map a AJAX request using spring. Now, I know that I need these two guys: HttpServletRequest, to get the message the client sent to me and parse it from JSON(most likely) to a Map and HttpServletResponse to put my message to the client. What I do not know is the right(simple, concise) way to do that... Here...

Spring-Ajax samples needed

i have a web application that uses spring framework and i want to use ajax in some pages (adding/deleting stuff from page,db without refreshing the whole page) tutorials and samples are needed for such stuff ...

portlet-mvc 3.0 + maven for websphere portlet: examples?

I'm trying to develop a websphere portal portlet using java, maven and spring-portlet-mvc 3.0.2.RELEASE but so far I'm not having a lot of luck. The problem that I'm having is that a lot of the tutorials are either outdated, incorrect, contradict eachother or a combination of all the above. Also I have to use RAD but the tutorials also c...

Spring Web: Correct way to have a single default ViewResolver

What is the best way to have every request be sent to a single ViewResolver - specifically in this case a JsonView? Was thinking this: <bean id="viewResolver" class="org.springframework.web.servlet.view.UrlBasedViewResolver"> <property name="viewClass" value="org.springframework.web.servlet.view.json.MappingJacksonJsonView" /> ...

Integrating JSF with Spring

I haven't implemented any code, I'm still working the overall architecture for a new application and this going to be the first time I use JSF+Spring. I need to put web services in front of the Spring service beans (business logic tier) since these beans could be accessed by other applications besides the presentation tier. While defini...

Spring MVC annotation config problem

I'm trying to improve my spring mvc configuration so as to not require a new config file for every servlet I add, but I'm running into problems. I've tried using this tutorial as a starting point, but I'm running into an issue that I can't figure out. The problem is that when I do a GET to my servlet, I get back a 404 error. Here's my c...

Spring MVC defaultValue for Double

Hi All, I'm trying to build a controller like this: @RequestMapping(method = {RequestMethod.GET}, value = "/users/detail/activities.do") public View foo(@RequestParam(value = "userCash", defaultValue="0.0") Double userCash) { System.out.println("foo userCash=" + userCash); } This works fine: http://localhost/app/users/detail/acti...