servlet找不到的问题
webroot下的jsp中img src="/servlet/TopologyServletweb.xml中也改了配置:
<servlet>
<servlet-name>TopologyServlet</servlet-name>
<servlet-class>com.Bmavweb.servlet.TopologyServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>TopologyServlet</servlet-name>
<url-pattern>/servlet/TopologyServlet</url-pattern>
</servlet-mapping>
还是不能显示
/Bmavweb/src/com/Bmavweb/servlet/TopologyServlet.java这是文件的路径 --------------------编程问答-------------------- img src="servlet/TopologyServlet
这样试试 --------------------编程问答-------------------- /servlet/TopologyServlet 还这个里面的servlet去掉 --------------------编程问答-------------------- 加上全路径试一下。request.getContextPath() --------------------编程问答-------------------- img src="servlet/TopologyServlet
不能有“/”去掉就可以了。。。。 --------------------编程问答-------------------- / 是绝对路径 ,没有/的是想对路径. --------------------编程问答-------------------- 关键是我直接localhost:8080/项目名/servlet/文件名 都提示is not available --------------------编程问答--------------------
<servlet>
<servlet-name>ImgServlet</servlet-name>
<servlet-class>base.servlet.ImgServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>ImgServlet</servlet-name>
<url-pattern>/servlet/ImgServlet</url-pattern>
</servlet-mapping>
访问路径
--------------------编程问答-------------------- basePath
<img src="${basePath }/servlet/ImgServlet" onclick="return changeImg();" name="imgvalicode" id="imgvalicode">
<c:set var="base" scope="page" value="${request.scheme}://${request.serverName}:${request.serverPort}" />
<c:set var="contextPath" scope="page" value="${request.contextPath}" />
<c:set var="basePath" scope="page" value="${base}${contextPath}" />
补充:Java , Web 开发