Spring Tool Suite
  1. Spring Tool Suite
  2. STS-2605

add possibility to generate Spring configuration inside web.xml

    Details

    • Type: New Feature New Feature
    • Status: Resolved Resolved
    • Priority: Minor Minor
    • Resolution: Complete
    • Affects Version/s: None
    • Fix Version/s: 3.0.0.M1
    • Component/s: None
    • Labels:

      Description

      It seems that it would be possible to create some templates for that:

      • one for DispatcherServlet declaration
      • one for ContextLoaderListener

      here is what we could generate:

       
      	<!-- The front controller of this Spring Web application, responsible for handling all application requests -->
      	<servlet>
      		<servlet-name>springDispatcherServlet</servlet-name>
      		<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
      		<init-param>
      			<param-name>contextConfigLocation</param-name>
      			<param-value>
      				<!-- TODO: please define location here such as /WEB-INF/spring-config.xml -->
      			</param-value>
      		</init-param>
      		<load-on-startup>1</load-on-startup>
      	</servlet>
      		
      	<!-- Map all requests to the DispatcherServlet for handling -->
      	<servlet-mapping>
      		<servlet-name>springDispatcherServlet</servlet-name>
      		<url-pattern><!-- TODO: please define url-pattern here --></url-pattern>
      	</servlet-mapping>
      

      And this is similar for the contextLoaderListener:

       
      	<!-- needed for ContextLoaderListener -->
      	<context-param>
      		<param-name>contextConfigLocation</param-name>
      		<param-value><!-- TODO: please define location here such as /WEB-INF/spring-config.xml --></param-value>
      	</context-param>
      
      	<!-- Bootstraps the root web application context before servlet initialization -->
      	<listener>
      		<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
      	</listener>
      

        Activity

        Hide
        Kaitlin Sherwood (c) added a comment -

        Fixed. I removed the comment and changed the indentation slightly.

        Show
        Kaitlin Sherwood (c) added a comment - Fixed. I removed the comment and changed the indentation slightly.
        Hide
        Michael Isvy (c) added a comment -

        Hi, I just tried out and it works well. That was quick .
        just a minor issue: the servlet is called "DispatcherServlet" and not "DispatchServlet".
        I see that the template has been called "dispatchServlet - DispatchServlet declaration". It should be "dispatcherServlet - DispatcherServlet declaration".

        Also, I see that the templates are proposed even for a non-Spring project. Wouldn't it make more sense to propose them for a project that has the Spring nature only? (if such thing is possible).

        Cheers,
        Michael.

        Show
        Michael Isvy (c) added a comment - Hi, I just tried out and it works well. That was quick . just a minor issue: the servlet is called "DispatcherServlet" and not "DispatchServlet". I see that the template has been called "dispatchServlet - DispatchServlet declaration". It should be "dispatcherServlet - DispatcherServlet declaration". Also, I see that the templates are proposed even for a non-Spring project. Wouldn't it make more sense to propose them for a project that has the Spring nature only? (if such thing is possible). Cheers, Michael.
        Hide
        Kaitlin Sherwood (c) added a comment -

        I was trying to shorten the name, but there wasn't a lot of shortening I could do. (I also thought about dspchrsrvlet, but dropped that idea pretty fast.) Adding the other two characters is a reasonable request; I will do that.

        It also makes sense to only add the @Autowired for Spring projects. I think it is reasonable to provide the constructor even for non-Spring projects.

        Show
        Kaitlin Sherwood (c) added a comment - I was trying to shorten the name, but there wasn't a lot of shortening I could do. (I also thought about dspchrsrvlet, but dropped that idea pretty fast.) Adding the other two characters is a reasonable request; I will do that. It also makes sense to only add the @Autowired for Spring projects. I think it is reasonable to provide the constructor even for non-Spring projects.
        Hide
        Kaitlin Sherwood (c) added a comment -

        Errr, the @Autowired was STS-1529, not STS-2605. There was a comment on STS-2605 about STS-1529, but STS-1529 is the original bug report.

        Show
        Kaitlin Sherwood (c) added a comment - Errr, the @Autowired was STS-1529 , not STS-2605 . There was a comment on STS-2605 about STS-1529 , but STS-1529 is the original bug report.
        Hide
        Kaitlin Sherwood (c) added a comment -

        Michael, please look at and comment on STS-2616.

        Show
        Kaitlin Sherwood (c) added a comment - Michael, please look at and comment on STS-2616 .

          People

          • Assignee:
            Kaitlin Sherwood (c)
            Reporter:
            Michael Isvy (c)
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:
              First Response Date: