spring-mvc

Spring MVC 3 and handling static content - am I missing something?

I am developing a webapp using Spring MVC 3 and have the DispatcherServlet catching all requests to '/' like so (web.xml): <servlet> <servlet-name>app</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>app</servlet-name> <url-p...

flushmode can only used one time?

Inside my applicationContext, I have 2 dao . if i assign my 2nd dao below to use flushmode, i will get error invalid; nested exception is org.xml.sax.SAXParseException: Attribute value "org.springframework.orm.hibernate3.HibernateAccessor.FLUSH_COMMIT" of type ID must be unique within the document. On the other hand, when i excluded flu...

How should I handle having one identical form on many pages in Spring MVC

Title says it all really. I have a login form that has some validation on many pages in my website. How best do I structure my controllers to avoid repeating the validation logic etc. Bear in mind some of these pages have their own controller requirements e.g. reference data. So one exactly identical controller cannot be used. The ...

What's the best way to get the current URL in Spring MVC?

I'd like to create URLs based on the URL used by the client for the active request. Is there anything smarter than taking the current HttpServletRequest object and it's getParameter...() methods to rebuilt the complete URL including (and only) it's GET parameters. Clarification: If possible I want to resign from using a HttpServletReque...

Spring MVC dynamically binding to and from a list of beans

Hi, I am new to spring MVC.In my application I need to bind dynamically generated textbox contents to a list of beans dynamically.I went through the spring mvc book for binding to lists.But before binding, we must not only initialize the collection, but populate it with objects. In my case I dont know the size of the list initially. ...

Exception resolver and dispatcher not forwarding

I set up a bean with an id of "exceptionResolver" made it an instance of org.springframework.web.servlet.handler.SimpleMappingExceptionResolver. Then I define two properties, "defaultErrorView" and "exceptionMappings". As I understand it this should catch any exceptions thrown in my web application and forward to the view I've specifie...

how to add filterclass into applicationContext?

I have a filterclass that i normally will put in web.xml. may i know how to specify it inside spring applicationcontext so that i able to use spring features in my fitlerclass? ...

No mapping found for HTTP request with URI: in a Spring MVC app

Hello All, I'm getting this error. my web.xml has this <servlet> <servlet-name>springweb</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <init-param> <param-name>contextConfigLocation</param-name> <param-value>/WEB-INF/web-application-config.xml</param-value> </init-p...

scope of a controller and a validator

We are developing an application using Spring MVC. There is a page which displays list of user, a check box next to it, and a submit button at the bottom of the page. A logged in user can select those check boxes and submit, currently a controller checks whether the selected user list is empty or not and acts accordingly. Should we just...

How to load themes from a database in Spring MVC based on user-agent , etc

Hi I am brand new to Spring web MVC. I am trying to create a simple 1 paged site that will check the users browser and display the current theme for that browser. If its a mobile app, I need to allow the user a button to switch to the regular site. Also the current theme for mobile and non-mobile is stored in a database, which inclu...

Accessing scoped proxy beans within Threads of

I have a web application running in tomcat where I'm using a ThreadPool (Java 5 ExecutorService) to run IO intensive operations in parallel to improve performance. I would like to have some of the beans used within each pooled thread be in the request scope, but the Threads in the ThreadPool do not have access to the spring context and ...

JSPs not displaying objects from model in Spring

I have what should be an easy issue to solve, but I'm having no luck. In my servlet-servlet.xml file, I have the following beans (in addition to others): <bean id="viewResolver" class="org.springframework.web.servlet.view.UrlBasedViewResolver"> <property name="viewClass" value="org.springframework.web.servlet.view.JstlView" /> <prop...

spring mvc: detect if an exception has been thrown while loading the context

I have a spring mvc application and we run tests with it using jetty. Sometimes the loading of the context totally fails, because bad xml or because Class Not Found exception or because a bean throws an exception in the constructor, setter or init method. In such a case I would like to to stop the application with System.exit(1) or tak...

Use part of the URL as an argument to a controller in Spring MVC

For example, with the URL foo.com/bar/99 99 will be available directly to a method in the controller as an argument. The controller is mapped to /bar For anyone familiar with ASP.NET MVC or Django, this would be similar to routes.MapRoute in the former and using (?P\d+) in urlpatterns in the latter. It would be possible to process ...

spring mvc: get the part url of the current request relative to the controller

In spring mvc I have a controller that listens to all requests comming to /my/app/path/controller/*. Let's say a request comes to /my/app/path/controller/blah/blah/blah/1/2/3 How do I get the /blah/blah/blah/1/2/3 part, i.e. the part that matches the * in the handler mapping definition. In other words I am looking for something simila...

getting started with spring framework

What is the best way to start with spring framework, I've already got a book Spring in action 2nd edition august 2007, but here is the thing, I'm missing some general knowledge concerning this framework and java. I've started reading the book but its not very clear to me, its clear what the author is trying to accomplish but I can't seem...

Where does ASP.NET MVC fall short against Ruby on Rails, CakePHP, et. al.?

I've been working quite extensively with ASP.NET MVC and I find it extremely useful (compared to WebForms), however I have some experience with other MVC frameworks and I feel there are definite gaps in capability. For one, in Drupal you can hook into just about anything and override it's View action. e.g. You can hook into the Drupal f...

A "Portlet-Like" java technolgy for a Web app

Hi, Do you know a technology which can provide me a portlet-like interface? But I do not want to use JSR 168/268 portlet specifications and a portlet container. The reason is: My web app is a product which can be installed on the client's server (it can be weblogic/websphere/tomcat). Packing the portlets container along with my applica...

@Secured service methods and spring ws

I have the following project structure: base project (service layer, model) web project webservice project where both the web project and the web service project depend on the base project and use services provided by it. I make heavy use of the Spring Framework which means the Services are Spring Beans with methods secured by the...

How to define Spring datasource in controller ?

Is it possible to define a datasource connector in a Spring controller ? I'm working on a tool : synchronize a source table to a target table. I would define source and target in my controller (to synchronize different databases - in my view I can select different source and target databases). Actually, I define my datasource in file c...