Admit that Spring is very hard to configure. If you are like me and you do not setup a new Spring project each month you would most likely search it up on google for answers. Admit it once more that you do not always find what you are looking for. And its true, its a mess out there with different tutorials showing you Spring 2.5 and Spring 3.0, and you do not know whats what immediately. In this article I will show you how to configure Spring 3 MVC for use with JavaScriptMVC 3.0.
Its not a straight forward procress and there is no tutorials out there for connecting a JavaScriptMVC3.0 widget to a JSON REST service made with Spring. This is the only tutorial so far to include a full guide on how to get everything working. After that you might need to finetune the xml to be less and slicker, but for this example what I will show you will do the magic for now.
1. Download JavaScriptMVC
2. Create a user Model and edit the /yourapp/yourapp.js:
3. Setup a basic Spring 3 web project 4. In the dispatcher servlet configuration make sure that annoations is enabled: <!-- Scans the classpath of this application for @Components to deploy as beans --> <context:component-scan base-package="com.yourdomain.app" /> <!-- Configures the @Controller programming model --> <mvc:annotation-driven /> Also add a negotiating content resolver bean:
If you get an error relating to the p thing in the above bean declaration, add the following to the beans definition:
xmlns:p="http://www.springframework.org/schema/p"
5. Create a controller and check that you can access the list method properly, your browser should popup with a download dialog due to the ignoring of accept headers
Also create the needed UserModel:
6. Edit the /yourapp/models/user.js:
7. Execute:
js yourapp/scripts/clean.js
js yourapp/scripts/build.js
And copy the following files to your web contents folder:
yourapp/yourapp.html
yourapp/production.css
yourapp/production.js
steal/steal.production.js
The yourapp.html page should now load properly and I leave you to code the rest of the user.js Model.
I will answer any questions and comments to this article. So feel free to ask questions or correct my mistakes.
Good luck!
Post a Comment