[英]How to map jsp class in web.xml?
I am trying to map my compiled jsp class which is available in org.apache.jsp folder in tomcat server folder to the web.xml file so that I don't want to ship my jsp code. 我正在尝试将我的已编译jsp类映射到web.xml文件,该类在Tomcat服务器文件夹中的org.apache.jsp文件夹中可用,因此我不想发送我的jsp代码。
I am using following code, but getting HTTP Status 404 - . 我正在使用以下代码,但获得HTTP Status 404- 。 I cross checked, paths are correct and class files are also available in that path I don't know why i am getting this error.
我交叉检查,路径是正确的,并且在该路径中也可以使用类文件,但我不知道为什么会收到此错误。
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<servlet>
<servlet-name>org.apache.jsp.index_jsp</servlet-name>
<servlet-class>org.apache.jsp.index_jsp</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>org.apache.jsp.index_jsp</servlet-name>
<url-pattern>/index.jsp</url-pattern>
</servlet-mapping>
</web-app>
Can any one help me to fix this? 谁能帮我解决这个问题?
you must use jsp-file tag for jsp mapping in web.xml 您必须在web.xml中将jsp-file标记用于jsp映射
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<servlet>
<servlet-name>org.apache.jsp.index_jsp</servlet-name>
<jsp-file>org.apache.jsp.index_jsp.jsp</jsp-file>
</servlet>
<servlet-mapping>
<servlet-name>org.apache.jsp.index_jsp</servlet-name>
<url-pattern>/index_jsp.jsp</url-pattern>
</servlet-mapping>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.