Announcement Announcement Module
No announcement yet.
Annotations and Controller Naming Conventions in Spring 2.5 + Netbeans 6.7 Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Annotations and Controller Naming Conventions in Spring 2.5 + Netbeans 6.7

    After about three weeks of wanting to kill my self (This was more common 12 years ago when I started programming, not now however), I am finally decided to ask for some help..

    I usually can't stand n00bs who read ZERO documentation or blogs and then ask ignorant questions, so I've waited a while to finally see if I can't get some answers...

    I am doing a massive rewrite of an old PHP site, HUGE site, and of all the Java frameworks, I really like Spring MVC's docs, community and seemingly flexible architecture.

    However, like many Java frameworks, their complexities making "rapid development" a completely worthless venture. Here in lies the problem...

    1) I want to use Annotations for Controllers and Actions

    2) I want to implement MultiActionController interface and group my actions by controller

    3) I would like URL's to look like this

    4) I want the Controller and Action portion of the URL to be map to the correct controller and action automatically with no XML config

    5) I would like the URL to NOT be case sensitive which I believe is possible with Spring.. I remember seeing some classes and config for this some where. But this is not a deal breaker.

    6) I want to develop the app using NetBeans 6.7 starting with the default web app project using the Spring MVC framework selected for the framework.

    That's it.. That' all I am trying to accomplish.. In my project, I have failed for three weeks to even show a view.

    I have used RoR, CakePHP, MVC, Joomla 1.5, and so many other MVC frameworks without any trouble. The concepts are universal... It's 100% ridiculous that a developer who's been coding for over 10 years cannot pick up a simple MVC framework, read the docs and create a site without having to loose sleep for three weeks lol.. I mean, seriously, am I the the only one here who thinks it's a bit silly that the default netbeans project using the Spring MVC framework doesn't use Annotations and only allows simple .htm file references to views? Not to mention doesn't even support Multiple actions per controller by default lol.. My goodness, it's like the default project was created for someone with a 3 page web app!

    ** OK ranting done **

    If any one would like to post their dispatcher-servlet.xml, web.xml and applicationContext.xml so I can see how to configure what I am looking to do I would appreciate it like none other :-)

    Thanks in advanced!

  • #2


    Here is a tutoriel on the web for starting



    • #3
      I appreciate the tutorial however it meets just about none of my requirements lol...

      1) It's using .htm extension
      2) It's already more complex then it needs to be using Jetty and Mavin
      3) Is not netbeans lol (Why do people still use Eclipse again?)
      4) Controllers and annotations are not used nor does it show how to use the MultiActionController

      In the time it took to get just ONE response on this issue, I have already setup and configured a new app using Wicket 1.4.. Been able to read tutorials which CLEARLY showed me how to use the framework with it's ZERO config, ZERO xml setup..

      I have also setup my own set of controllers based on convention and in the last hour can do 100% more with Wicket then I could with Spring MVC.. Not to mention I've eliminated 40 layers of complexity and instead have just two layers... That's it lol..

      I doubt anyone is going to actually be able to show me what I am looking to do. I am sure it's possible, I've read through the Spring Source documentation, I can even tell you what base classes they use lol.. But no one can seem to get it working..

      That ladies and gentleman is a problem. I fear the Spring is merely pushing their training and books instead of writing REAL plugins and test projects that actually show the real day to day use of Spring specially for web 2.0 developers.

      I guess I can cross Spring MVC off of my list and continue with Wicket, which by the way is form apache foundation, so it's not going any where! :-)


      • #4


        You can have sample here :

        I believe you should not use MultiActionController but annotation with spring 3 or 2.5

        you can find some example in the web like here



        • #5
          Annotations and Controller Naming Conventions in Spring 2.5 + Netbeans 6.7

          Hi Joshua,

          speaking for the NetBeans team, we are aware that the NetBeans support for Spring could be improved and enhanced, especially in the light of the upcoming Spring 3.0 release. We are eager to hear input from real users such as yourself, and we would like to know what specific improvements you would like to see, so we can focus on them in the next release. Feel free to either file enhancement/feature requests in the NetBeans issue tracker:, or drop me an e-mail at petr.jiricka at sun dot com. Thanks,



          • #6
            I appreciate the posts, links, etc.

            Please understand I am not trying to be a complete @$$ here... lol Sometimes things come across differently online then vocally, but while these examples show usage of annotations, or some might show how to create a basic app.. They are far what what I am looking for.

            I can created a new project and setup a new controller for every action and have that working with a simple .htm extension in no time...

            Unfortunately, I do not want an app like this haha..

            If someone where to create a netbeans project, which means the following, I would be happy, impressed and belated!

            1) Support for extension-less URLS (
            2) Controllers would allow behavior as if inheriting from MultiActionController
            3) I want to use each controller to use several actions
            4) I want URL binding to be done using annotations
            5) I want controllers defined using annotations and not XML, heck, even using the Url Controller name binding functionality would make me happy.

            I have tried this for many many weeks now and cannot get it to work.. I can follow every single tutorial on the web for doing "A", or for doing "B" but when I combine it to make "C" it's always a no-go.. SOMETHING isn't playing right and I am not even getting an exception haha... Heck, I think Spring is finding the controller and action but it's still a no go for some reason.

            Matter of fact, the ONLY errors I am getting in the application are 404 errors, not one exception!

            Thanks, if anyone can come up with such a configured project, which shouldn't be that hard to ask for from a framework which boasts such a following I would be eternally grateful, and might even be will to throw some cash your way!


            • #7
              Making Progress!

              Well I sat down today, and basically spent... THE ENTIRE DAY working from scratch on a new Spring 2.5 MVC app trying to replicate my requirements and making them work one by one..

              Here I will place my configs and Controller setup so that people can do the same thing, but there is still ONE LAST THING... Just one small detail...

              1 Problem left to solve:
              The only way I could get pretty urls (
              was too add a prefix in the servlet-mapping -> url-patter node inside of web.xml.

              For instance, this is what I have for my web.xml...

              <?xml version="1.0" encoding="UTF-8"?>
              <web-app version="2.5" xmlns="" xmlns:xsi="" xsi:schemaLocation="">

              As you can see, I have placed "/app/*" as the url-pattern. Now don't get to exited yet... Many of you are already thinking just remove the /app prefix and use /* and poof... NO SUCH LUCK my friends.. This is not struts2 nor Wicket... lol...

              Now that you're all aware of the last and final piece of the puzzle let me present the configs and controller setup I am using...

              <?xml version="1.0" encoding="UTF-8"?>
              <beans xmlns=""
                  <!--bean id="propertyConfigurer"
                        p:location="/WEB-INF/" />
                  <bean id="dataSource"
                        p:password="${jdbc.password}" /-->
                  <!-- ADD PERSISTENCE SUPPORT HERE (jpa, hibernate, etc) -->
              <?xml version="1.0" encoding="UTF-8"?>
              <beans xmlns=""
                  <context:component-scan base-package="com.test.controllers" />
                  <bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping"/>
                  <bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter"/>
                  <bean id="viewResolver"
                        p:suffix=".jsp" />
              and the Web.xml you can view above

              Here is what I am using for a controller in package "com.test.controllers"


              package com.test.controllers;
              import javax.servlet.http.HttpServletRequest;
              import javax.servlet.http.HttpServletResponse;
              import org.springframework.stereotype.Controller;
              import org.springframework.web.bind.annotation.RequestMapping;
              import org.springframework.web.servlet.ModelAndView;
               * @author jholmes
              public class TestController {
                  public ModelAndView index(HttpServletRequest request, HttpServletResponse response) {
                      return new ModelAndView("test", "model", "Model Here and I aint going away!");
                  public ModelAndView profile(HttpServletRequest request, HttpServletResponse response) {
                      ModelAndView mav = new ModelAndView();
                      mav.addObject("message", "You Don't even know... BLAH BLAH BLAH");
                      return mav;
                  public ModelAndView update(HttpServletRequest request, HttpServletResponse response) {
                      ModelAndView mav = new ModelAndView();
                      mav.addObject("message", "You Don't even know... BLAH BLAH BLAH");
                      return mav;

              I have attached a screen shot of my netbeans project.. any other help?