spring-mvc

What should i use i if need a custom converter when using @RequestParam ???

I if have a method signature as follows public void deposit(@RequestParam("accountId") Integer accountId, @RequestParam("amount") BigDecimal amount) {...} And because i have a locale specific decimal value which needs to be converted to a BigDecimal, is there some annotation which allows me to set up incoming data...

url link is too long to fit in one line Spring MVC

How to avoid break in long url link sent through Spring MVC web app? It is a redirect url sent to email box in case of reset password request http://man-01668:9090/HDCdemo/demoservice/portal/resetpassword.htm?pfpc=tMgmMyBhpVRi1pZq&redirect_url=http://localhost:8080/HDCdemo/demoservice/portal/myprofile.htm?_flowId=citizenportal/mypro...

Apache Tiles : change template page at runtime

Hi all, I have a question : suppose that in a spring MVC 3.0 enviroment i manage Views with Tiles : I have a xml file with definitions of all views. Every view extends a specific template. I have two templates : one for rendering a completeDOM () and one for partialDOM (.....).The problem is, there are some views that can be retrieved i...

Spring MVC 3.0 accessing Session Variable

Hi, I have the following problem, I have configured the following class which should be stored in session. <bean id="Users" class="com.doolloop.DlUser" scope="session"> <aop:scoped-proxy/> </bean> Then I in my Dispatcher servlet I would like to access this class user and set @RequestMapping(value="/authenticate.do",method = Reques...

Interrupt HTTP POST in Spring MVC with maxUploadSize?

I've configured a MultipartResolver in my Spring MVC webapp and set its maxUploadSize property to 1MB. <bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver"> <property name="maxUploadSize"> <!-- 1MB max --> <value>1048576</value> </property> </bean> When a user ...

To retain vertical scroll positon even after clicking save button in JS

function successfullySaved() { document.getElementById("successfullySaved").value.focus(); } this function doesnt wrk.. should i try with using scrollBottom? plz suggest me code so that the succesful msg(comes into pic only onclick of Save button in my case) which is getting displayed at the bottom of the page shd retain the scroll ba...

JSON character encoding

Hi, My Java web application submits an AJAX request that returns JSON such: {'value': 'aériennes'} When 'aériennes' is displayed in the webpage, it appears as 'a�riennes', so I guess there's some kind of character encoding problem. The AJAX response headers include Content-Type application/json which doesn't appear to include a...

Serve JSON "as is" from Spring controller using content negotiation

In my webapp, all my message converters are in place, and if I change getContent below to return a bean/pojo, it returns as " application/json;charset=UTF-8", which is expected, but I now want to serve JSON "as is". E.g. I have a simple stub web service with which users can PUT a blob of JSON content which is persisted somewhere, and th...

JQuery/Spring: How to POST JSON but return html

When I post a JSON to the server and return a normal View string from the Spring controller, my jQuery is not hitting the "success" function. My Controller: @RequestMapping(value = MappingConstants.RULE_ASSIGNMENT, method = RequestMethod.POST) public String saveRuleAssignment(@RequestBody RuleAssignmentCO ruleAssignment) { // Some con...

Finding Locale from Controller in Spring MVC

I'm using Sprinng 3.0. How do I find the current locale set by a LocaleResolver within an annotation-based controller? Thanks. ...

Spring framework best practices: deploying a non-bean compliant component

I want to build an MVC app using Spring (first timer here). As such I want to embed Jetty as the servlet engine. Jetty however doesn't stricly follow the java beans pattern, so I can't launch some classes from Spring (they use overloaded setters or non setter init methods like addXYZ). What is the accepted/recommended practice for stru...

spring-mvc + jpa: data binding

I have simple application which manages football teams and matches. I am using JPA, in the form editMatch.jsp i have property team_1, team_2 (instance of class Team) for choosing the team from the list. The problem is when editing match, the team_1 and team_2 dont select in the list, and after submitting the error message is: Property t...

Spring: How should application+web contexts be organized?

The scenario: Start the app and load ClassPathXmlApplicationContext in main(), this starts a Jetty webapp. dispatcher servlet then loads a XmlWebApplicationContext dispatcher servlet then looks for WEB-INF/applicaitonContext.xml to load as the root context I'm just trying to get my head around contexts. Should I use 3 contexts as ...

Mapping Path Variable to Command Property

@RequestMapping(value = "/post/{postThreadId}", method = RequestMethod.GET) @ResponseBody public String paramTest(PostParams params) { return params.toString(); } Spring MVC Path Variable ("postThreadID") can be mapped to Command object field? PostParams have setPostThreadId(int ...) But, it looks not working. ...

Spring 3 MVC - Controller is called but views are not found

Hi, I'm trying to set up a skeleton Spring 3 MVC project but i'm having difficulties getting the views to render. I have followed the structure as described in the mvc-basic sample project and at http://blog.springsource.com/2009/12/21/mvc-simplifications-in-spring-3-0/?utm_source=feedburner&amp;utm_medium=feed&amp;utm_campaign=Feed%3A+...

[Spring framework Form Validation] disallowed field validation

Hi there I'm new with spring framework. I'm currently building some news manager form. Here a sample of my news entity : class News { @NotNull long id; @NotNull long idAuthor; @Size(max=255) String content; } As you can see, I use JSR303 annotation validation with Spring. I want to validate my "news edit form...

Different classloaders cause ClassCastException when persisting data via Spring

I'm creating an MVC Spring webapp. Using: Jetty (servlet container), DataNucleus (dao platform), DB4O (embedded datastore). When I persist an object (done from within a Spring Controller) using JDO from DataNucleus, it stores to the DB fine. @PersistenceCapable public class Test { @Persistent private String testString; //g...

Spring MVC and JSR-303 hibernate conditional validation

I've a form I want to validate. It contains 2 Address variables. address1 has always to be validated, address2 has to be validated based on some conditions public class MyForm { String name; @Valid Address address1; Address address2; } public class Address { @NotEmpty private String street; } my controller aut...

Make something after remember me authentication ?

greetings all i am using spring security 3.0.2 and i am using the following configuration for remember me <http use-expressions="true" > <remember-me token-repository-ref="tokenRepository" token-validity-seconds="1209600"/> <beans:bean id="tokenRepository" class="org.springframework.security.web.authentication.reme...

Do I need to use Google Account Authentication instead of Spring authentication to avoid a Firesheep cookie-sniffing attack?

I was reading about Firesheep and wondering how I can protect my Spring MVC 3.0 site against attacks like this: It's extremely common for websites to protect your password by encrypting the initial login, but surprisingly uncommon for websites to encrypt everything else. This leaves the cookie (and the user) vulnerable. HTT...