I’m doing a lot of our validation with Hibernate and Spring Annotations like so: And then in the controller it’s called in the arguments: But I would like to decide the group used based on some logic in the controller method. Is there a way to call validation manually? Something like result = account.validate(Account.Step1.class)? I am aware of creating your
Tag: spring-mvc
Redirect to an external URL from controller action in Spring MVC
I have noticed the following code is redirecting the User to a URL inside the project, whereas, the following is redirecting properly as intended, but requires http:// or https:// I want the redirect to always redirect to the URL specified, whether it has a valid protocol in it or not and do not want to redirect to a view. How
How to return a text file with Spring MVC?
The string is generated inside the Controller. What I want is to send back to the user a Window where he can save a file which contains the myString. It clearly doesn’t work in this current state and I am stuck at the moment. Answer here is a sample: PS: don’t forget to put some random stuff in your url
Download file with original file name
In my project I am uploading a file. While uploading, I am saving its original file name and extension in a database and saving that file with some GUID on server, generated GUID is also stored in database along with file name and extension. For example- -File name for uploading is questions.docx -Then orignalFileName will be “questions” -FileExtension will be
Spring DeferredResult setResult causing 404
I am using the new spring 3.2 async servlet requests. All works well except in this one scenario… When someTest() is true spring/tomcat returns a 404. I am not sure how I should go about this or why this happens? I assume it might be because the Servlet Async Context has already been created. Is this a bug or am
Bind elements to a list with spring mvc ModelAttribute
The question is based on getting a spring model attribute list element using an index from javascript on which explains that each name of the html element must contain an index. Example user[0] I have a form that allows the user to dynamically add or remove elements from the list before submitting it. Let me put an example: we add
alternative to GrantedAuthorityImpl() class
I want an alternative to GrantedAuthorityImpl() class. I want this in spring security implementation. GrantedAuthorityImpl() class is deprecated. Hence I want an alternative solution to it. My code : Answer The class GrantedAuthorityImpl has been deprecated – you can use SimpleGrantedAuthority instead:
Error in Java Import statement “The import javax.validation.constraints.NotNull cannot be resolved”
After developing Spring roo project, I found following errors in class: I am using STS 3.1.0.RELEASE How can this be rectified? Answer The jar containing this class must be added to the build path of your project: http://mvnrepository.com/artifact/javax.validation/validation-api/1.0.0.GA
Making Spring 3 MVC controller method Transactional
I am using Spring 3.1 and have my DAO and service layer(transactional) written. However in a special case to avoid a lazy init exception I have to make a spring mvc request handler method @transactional. But It is failing to attach transaction to that method. Method name is ModelAndView home(HttpServletRequest request, HttpServletResponse response). http://forum.springsource.org/showthread.php?46814-Transaction-in-MVC-Controller From this link it seems it
@Autowired and @Service working from controller but not from a different package
I need help understanding the concept behind @Autowired and @Service. I have a DAO defined with @Service and controller with @Autowired and everything seems fine, however, I use the same @Autowired in a different class then it does not work. Example: Service Controller The above all works fine. However, If I want to use MyService in a POJO then it