org.springframework.boot.web.servlet

Class ServletRegistrationBean<T extends Servlet>

    • Constructor Detail

      • ServletRegistrationBean

        public ServletRegistrationBean(T servlet,
                                       String... urlMappings)
        Create a new ServletRegistrationBean instance with the specified Servlet and URL mappings.
        Parameters:
        servlet - the servlet being mapped
        urlMappings - the URLs being mapped
      • ServletRegistrationBean

        public ServletRegistrationBean(T servlet,
                                       boolean alwaysMapUrl,
                                       String... urlMappings)
        Create a new ServletRegistrationBean instance with the specified Servlet and URL mappings.
        Parameters:
        servlet - the servlet being mapped
        alwaysMapUrl - if omitted URL mappings should be replaced with '/*'
        urlMappings - the URLs being mapped
    • Method Detail

      • setServlet

        public void setServlet(T servlet)
        Sets the servlet to be registered.
        Parameters:
        servlet - the servlet
      • getServlet

        public T getServlet()
        Return the servlet being registered.
        Returns:
        the servlet
        Since:
        2.0.4
      • setUrlMappings

        public void setUrlMappings(Collection<String> urlMappings)
        Set the URL mappings for the servlet. If not specified the mapping will default to '/'. This will replace any previously specified mappings.
        Parameters:
        urlMappings - the mappings to set
        See Also:
        addUrlMappings(String...)
      • getUrlMappings

        public Collection<String> getUrlMappings()
        Return a mutable collection of the URL mappings, as defined in the Servlet specification, for the servlet.
        Returns:
        the urlMappings
      • addUrlMappings

        public void addUrlMappings(String... urlMappings)
        Add URL mappings, as defined in the Servlet specification, for the servlet.
        Parameters:
        urlMappings - the mappings to add
        See Also:
        setUrlMappings(Collection)
      • setLoadOnStartup

        public void setLoadOnStartup(int loadOnStartup)
        Sets the loadOnStartup priority. See ServletRegistration.Dynamic#setLoadOnStartup for details.
        Parameters:
        loadOnStartup - if load on startup is enabled
      • getDescription

        protected String getDescription()
        Description copied from class: RegistrationBean
        Return a description of the registration. For example "Servlet resourceServlet"
        Specified by:
        getDescription in class RegistrationBean
        Returns:
        a description of the registration
      • getServletName

        public String getServletName()
        Returns the servlet name that will be registered.
        Returns:
        the servlet name