spring-mvc

error handling with spring + servlet spec

I have a web-app (2.5 servlet spec) with a spring dispatcherservlet handling anything coming on /error/* and an error page configured to route that to /error/ something like this: <servlet> <servlet-name>errorServlet</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <load-on-star...

Spring MVC or Grails?

I'm new to the web programming world, and I'm trying to learn about various Java MVC frameworks available. Through my research, I came across Spring MVC and Grails. My question is: which one is better for developing enterprise web applications, or is there another option I haven't run across yet? Important considerations: Must be su...

How do you load a bean into Spring MVC's application context?

As I understand it, Spring MVC application has two distinct contexts, the application context and the web context, which are controlled by applicationContext.xml and dispatcher-servlet.xml, respectively. Inside my controllers, how do I go about loading a bean into either of these contexts? Note that I am aware of Getting Spring Applica...

How to determine Controller for given url (spring)

Using spring DefaultAnnotationHandlerMapping how can I lookup the Controller that would ultimately handle a given url. I currently have this, but feels like there ought to be a cleaner way than iterating over 100s of request mappings: public static Object getControllerForAction(String actionURL) { ApplicationContext context = getAp...

How should I redirect the second page in Spring framework

My application has 3 JSP pages: one is login.jsp, and the others are loginSuccess.jsp and loginFail.jsp. If the username and the password in the login form are correct then it goes to the loginSuccess page but when the username and password are not correct, it doesn't go to the loginFail page. What do I need to do to get it to work? ...

How can i have previous value of checkbox in Spring?

Is it posssible to have the previous value of checkbox alongwith new value? My problem is, i have to execute some code, only if the value of checkbox is true, also if it was already true, then i am not suppose to perform the same action again. Currently what i am doing is , for every checkbox i am having previous value holder too. If t...

Automatic dynamic binding in spring

I am using spring MVC and would like to expose default validator for javascript to use. I have a bunch of controllers extending a common abstract class and bunch of validators implementing a common interface. The situation is something like this: public abstract class AbstractController { protected Validator validator; } public class ...

Spring MVC View

What are you guys using for your view in Spring MVC. I know Spring MVC has a wide support for views but I'm having trouble finding what works well, what view to use when, etc. Any insight would be great! ...

UrlFilenameViewController does not return View (Spring-MVC)

Hi, According to Spring framework API UrlFilenameViewController's purpose is: Transforms the virtual path of a URL into a view name and returns that view If i request for /info.xhtml, its logical view name is info See UrlFilenameViewController documentation Both web.xml and controller is mapped according to /WEB-INF/web.xml <...

MVC Database Image Display spring

In the context of an MVC application (using Spring MVC in this case), given that I have some image paths stored in a DB. How can I display these in the view? Is it the controllers job to load them and then pass them to the view? If so, how is this done in Spring MVC using JSP? Thanks ...

Spring: escaping input when binding to command

Hi! How do you handle the case where you want user input from a form to be htmlEscape'd when you are binding to a command object? I want this to sanitize input data automatically in order to avoid running through all fields in command object. thanks. ...

Can SpringMVC be configured to process all requests, but exclude static content directories?

If I map my spring application to process all incoming requests ('/*'), then requests for static content return 404's. For example, a request for "myhost.com/css/global.css" would return a 404, even though the resource exists as Spring intercepts the request. The alternative is to map SpringMVC to a subdirectory (for example '/home/'), ...

Does Spring-MVC annotation based bean validation support for collection-based property ? (Spring-MVC)

Hi, I have a command class named Parent as follows: public class Parent { private List<Child> childList; // getters and setters } And a Child class according to public class Child { @NotBlank private String name; @NotBlank private String email; @NotBlank private Integer age; } In Spring valid...

jdo integration with spring..?

is it a must to use kodo jdo if want to integrate with spring? from my understanding kodo is not free. any free implementation of jdo with spring? any such demo come with source code? ...

What's the most AGILE APPROACH to validate Spring-MVC command (speeds up validation implementation on server side) ? (Spring-MVC)

Hi, I am starting a new Spring-MVC project. Validation is a important feature in any project. This way, i have seen many approachs as follows: Spring Validator interface It sounds like a Struts 1.x validation. In my opinion, it is not agile. Commons Validator I think it is better than Validator interface Annotation based bean ...

How to get the request context in a freemaker template in spring

Hi, How to get the request context path in freemarker template when using with spring. My view resolver is like this <bean id="freeMarkerViewResolver" class="learn.common.web.view.FreemarkerViewResolver"> <property name="order" value="1" /> <property name="viewClass" value="org.springframework.web.servlet.view.fr...

map url to controller

in my applicationContext.xml, i put this <bean id="something" class="com.to.theController"/> in com.to.theController i have this method like @Controller public theController{ @RequestMapping(value="/api/add", method= RequestMethod.GET) public String apiAddHandler(Model model){ model.addAttribute("api", new Api()); re...

springsource tool suite (eclipse) tutorial?

any tutorial on this how to enable spring support for my existing project,and fast way to create my bean defination file.xml files..? i know manually way of creating applicationcontex.xml..etc .but wonder is there any fast way when using springsource tool suite. tutorial,article,video guide would be good ...

spring mvc annotation @RequestAttribute similar to @RequestParam

Hi, I would like add an annotation similar to @RequestParam, though have it pull the values from the request attribute rather than the request param... Is there an example or explanation how to create my own annotation for this and the handler / binder needed as well? Thanks ...

log4j:WARN No appenders could be found for logger in web.xml

I already put the log4jConfigLocation in web.xml, but still, i get warning log4j:WARN No appenders could be found for logger (org.springframework.web.context.ContextLoader). log4j:WARN Please initialize the log4j system properly. what did i missed out? <context-param> <param-name>contextConfigLocation</param-name> <par...