
上面是目录结构
Index.java的Servlet代码是:
package ce.shi.deng.tao;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class Index extends HttpServlet {
private static final long serialVersionUID = 1L;
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
request.getRequestDispatcher("/themes/tuzuan/index.jsp").forward(request, response);
}
}
index.jsp 的 代码是:
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
index
index
all
图片和css都不显示,请求状态是200
还是是当作HTML来访问了
Resource interpreted as Image but transferred with MIME type text/html: "http://localhost:8080/img/logo_38.png".
不知道为什么,请高手帮忙解答下
补充:
应该不是路劲问题,好像是请求类型错了,看下图,不知道为什么:

=======================分割线===========================

我把他设置成根目录了,这样不影响把,顺便把web.xml贴出来
DengTaoCeShi
index.html
index.htm
index.jsp
default.html
default.htm
default.jsp
Index
Index
ce.shi.deng.tao.Index
Index
/
All
All
ce.shi.deng.tao.All
All
/all
/all/
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
../../img/logo_38.png
用这个路径试试?
text/html是你图片引用出错而返回的错误信息(以html格式返回),而你图片引用出错的原因就是路径不对
亲测有效

=========分割线==========
web.xml配置
MyClass.java
测试结果。
就像楼上说的,你的路径少了项目所在的路径。
路径的问题吧。
http://localhost:8080/img/logo_38.png这个没有项目名称
ContextRoot 那是设置部署的路径...还有你这个视图是project Explorer最好切换成Package Explorer````这样层次更清楚