search

Home  >  Q&A  >  body text

java - 请问 /* 和 / 的区别是什么?

例如我在搭建Spring MVC时,在web.xml中进行如下基本的配置。请问<url-pattern>/*</url-pattern><url-pattern>/</url-pattern>的区别是什么?谢谢。

    <servlet>
        <servlet-name>dispatcher</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <init-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>classpath:applicationContext.xml</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>

    <servlet-mapping>
        <servlet-name>dispatcher</servlet-name>
        <url-pattern>/*</url-pattern>
    </servlet-mapping>
PHPzPHPz2813 days ago880

reply all(1)I'll reply

  • 高洛峰

    高洛峰2017-04-18 09:15:58

    I have also been confused about this problem. I saw a discussion on csdn http://bbs.csdn.net/topics/390610045
    If configured as /, springMVC will treat all .jsp.. as txt. The result is that the jsp source code is loaded directly in the browser

    reply
    0
  • Cancelreply