本文主要是介绍解决: /$%7BpageContext.request.contextPath%7D/login.jsp,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
JSP中的:${pageContext.request.contextPath} 无法解析,
程序运行后出现:/$%7BpageContext.request.contextPath%7D/login.jsp
不要慌,经过鄙人一下午的努力,终于找到可以解决问题的解决办法,
First:
这是由于web.xml的版本低导致的,这都不重要
创建项目时默认的web.xml文件是这样的:
<!DOCTYPE web-app PUBLIC"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN""http://java.sun.com/dtd/web-app_2_3.dtd" ><web-app><display-name>Archetype Created Web Application</display-name>
</web-app>
启动后就会报404错误;
此时:
Important:
找到你的Tomcat文件Tomcat\apache-tomcat-9.0.54\webapps\ROOT\WEB-INF下的web.xml文件:
<?xml version="1.0" encoding="UTF-8"?>
<!--Licensed to the Apache Software Foundation (ASF) under one or morecontributor license agreements. See the NOTICE file distributed withthis work for additional information regarding copyright ownership.The ASF licenses this file to You under the Apache License, Version 2.0(the "License"); you may not use this file except in compliance withthe License. You may obtain a copy of the License athttp://www.apache.org/licenses/LICENSE-2.0Unless required by applicable law or agreed to in writing, softwaredistributed under the License is distributed on an "AS IS" BASIS,WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.See the License for the specific language governing permissions andlimitations under the License.
-->
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaeehttp://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"version="4.0"metadata-complete="true"><display-name>Welcome to Tomcat</display-name><description>Welcome to Tomcat</description></web-app>
删掉没用的内容,粘贴到项目的web.xml文件中去;
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaeehttp://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"version="4.0"metadata-complete="true"></web-app>
这篇关于解决: /$%7BpageContext.request.contextPath%7D/login.jsp的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!