Results 1 to 10 of 10

Thread: Struts AND Spring MVC

  1. #1
    Join Date
    Mar 2006
    Posts
    23

    Default Struts AND Spring MVC

    Hi!

    I would like to know if it is possible to use Struts together with Spring MVC in the same project. In fact I have already done the web tier with Struts and I would like to use spring support classes for JasperReports (witch use spring mvc in all examples I could see).

  2. #2
    Join Date
    Dec 2004
    Location
    Rotterdam, The Netherlands
    Posts
    162

    Default

    Yes it is.
    Kees de Kooter
    www.boplicity.net

  3. #3
    Join Date
    Mar 2006
    Posts
    23

    Question

    Ok, so now I would like to know where is done the redirection to Spring MVC or Struts. Is it in the web.xml with, for example, two servlets :
    - one for struts : action
    - one for spring : springaction

    <web-app>
    <context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>/WEB-INF/applicationContext.xml</param-value>
    </context-param>
    <listener>
    <listener-class>
    org.springframework.web.context.ContextLoaderListe ner
    </listener-class>
    </listener>

    <servlet>
    <servlet-name>action</servlet-name>
    <servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
    <load-on-startup>0</load-on-startup>
    </servlet>

    <servlet>
    <servlet-name>springaction</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherSe rvlet</servlet-class>
    <load-on-startup>1</load-on-startup>
    </servlet>

    <servlet-mapping>
    <servlet-name>action</servlet-name>
    <url-pattern>*.do</url-pattern>
    </servlet-mapping>

    <servlet-mapping>
    <servlet-name>springaction</servlet-name>
    <url-pattern>*.htm</url-pattern>
    </servlet-mapping>
    </web-app>

    Am i right?

  4. #4
    Join Date
    Dec 2004
    Location
    Rotterdam, The Netherlands
    Posts
    162

    Default

    Yes you are right!
    Kees de Kooter
    www.boplicity.net

  5. #5
    Join Date
    Mar 2006
    Posts
    23

    Default

    Thank you for your answer.
    I get an error when I try to access a .htm page:

    Error 500--Internal Server Error

    java.util.MissingResourceException: Can't find bundle for base name views, locale fr


    in the spring controller, I return new ModelAndView("/test.htm") with test.htm placed in the webroot directory...

    Any idea?

  6. #6
    Join Date
    Jul 2005
    Posts
    246

    Default

    Quote Originally Posted by Maxence
    Thank you for your answer.
    I get an error when I try to access a .htm page:

    Error 500--Internal Server Error

    java.util.MissingResourceException: Can't find bundle for base name views, locale fr


    in the spring controller, I return new ModelAndView("/test.htm") with test.htm placed in the webroot directory...

    Any idea?
    So do you have a views.properties file or not?

  7. #7
    Join Date
    Mar 2006
    Posts
    23

    Default

    No, i don't have any views.properties file. Must I create one?

    However, i did like in a tutorial (http://www.springframework.org/docs/...ep-Part-1.html) where the next view's path is hardcoded :
    "return new ModelAndView("hello.jsp");"

  8. #8
    Join Date
    Jul 2005
    Posts
    246

    Default

    Quote Originally Posted by Maxence
    No, i don't have any views.properties file. Must I create one?

    However, i did like in a tutorial (http://www.springframework.org/docs/...ep-Part-1.html) where the next view's path is hardcoded :
    "return new ModelAndView("hello.jsp");"
    I think you're misunderstanding the exception. The MissingResourceException means that you have probably declared a message properties file somewhere in your Spring configuration file with the name "views". Probably something like this:-

    Code:
    <bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource">
        <property name="basenames">
            <list>
                <value>views</value>
            </list>
        </property>
    </bean>
    Spring is expecting to find a text resources file called views.properties (or, since your locale is FR, views_fr.properties) that holds your internationalisation keys and text.

  9. #9
    Join Date
    Mar 2006
    Posts
    23

    Default

    Thank you Cowboy bob (and the others) for your answers, my problem is solved.

  10. #10

    Default

    Quote Originally Posted by Maxence View Post
    Thank you Cowboy bob (and the others) for your answers, my problem is solved.
    Maxence, the reason to use SpringMVC was only for the reports?? Did you gain any other benefit form SpringMVC and having worked in both could you elaborate on you eperience???

    Thanks,
    Franklin.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •