在編寫jsp時,如下代碼中的pageContext會報一個錯誤。
<a href="${pageContext.request.contextPath }/comm/activate_user">激活用戶數</a>
錯誤:
javax.servlet.jsp.PageContext cannot be resolved to a type
原因與解決:編寫時候報錯,當時發佈到jetty後能正常運行,這是因爲jetty中有jsp-api.jar。
所以,解決方法就是將jetty安裝目錄下的jsp-api.jsp(tomcat中也有)複製到工程的lib目錄下。
然後打個空格,重新保存一下jsp文件就可以了。
maven中添加一下依賴:
<dependency> <groupId>javax.servlet.jsp</groupId> <artifactId>jsp-api</artifactId> <version>2.2</version> <scope>provided</scope> </dependency>