1.jsp中request多种方法无法调用
导致request中的大部分get方法无法获取,是因为没有依赖的jar包。就像这样。这里不仅仅有getContextPath()方法报错,如果存在这个问题,大部分的request方法都不可用。
为了解决这个问题,需要重新配置tomcat,在项目中添加tomcat下的lib包
步骤:
File->Project Structure->Libraries->点击“+”->java;添加本机目录下的tomcat的lib包
问题解决:
2.Jstl的Maven依赖配置
今天在配置项目时发现导入jtsl的jar包出错,项目中没有jtsl的jar包,jstl 需要手动引入,于是在pom.xml中添加依赖如下:
<dependency>
<groupId>javax.servlet.jsp.jstl</groupId>
<artifactId>jstl-api</artifactId>
<version>1.2</version>
<exclusions>
<exclusion>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
</exclusion>
<exclusion>
<groupId>javax.servlet.jsp</groupId>
<artifactId>jsp-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.glassfish.web</groupId>
<artifactId>jstl-impl</artifactId>
<version>1.2</version>
<exclusions>
<exclusion>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
</exclusion>
<exclusion>
<groupId>javax.servlet.jsp</groupId>
<artifactId>jsp-api</artifactId>
</exclusion>
<exclusion>
<groupId>javax.servlet.jsp.jstl</groupId>
<artifactId>jstl-api</artifactId>
</exclusion>
</exclusions>
</dependency>
添加后运行正确,问题解决