本文记录使用springmvc时候的困惑,及解决的方法

坑:web.xml文件的version

开始建立项目时候新建mavenProject,此时默认的Dynamic Web Module是2.3,
但是在2.4版本以下默认关闭el表达式,而且项目一般都没有src/main/java等source folder,jsp文件有错
因此jsp文件中${}内容全不出现

解决

建立web project可以选择Dynamic Web Module然后添加maven,上面的问题都不会出现的


坑:对应的servlet.xml

不是个都叫HelloWeb-servelt.xml!!!!
不是个都叫HelloWeb-servelt.xml!!!!
不是个都叫HelloWeb-servelt.xml!!!!
仔细看文档啊啊啊啊!!!

The web.xml file will be kept WebContent/WEB-INF directory of your web application. OK, upon initialization of [servlet-name] DispatcherServlet, the framework will try to load the application context from a file named [servlet-name]-servlet.xml located in the application’s WebContent/WEB-INF directory.

servlet-name就是包名


生成项目的url是谁?

建立时候时,是根据maven中的Artifact id确定项目的url
因此在配置web.xml时,注意servlet名字要与Artifact id相同,且配置的[servlet]-servlet.xml要与其对应
也就是上面的问题