123456147% 2021-12-03 20:31 采纳率: 64.7%
浏览 29
已结题

已经设置utf-8 jsp 中文和图片还是乱码

<%@ page language="java" contentType="text/html; charset=UTF-8" import="entity.*,java.util.*,dao.*,dao.impl.*"
    pageEncoding="UTF-8"%>
     <%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="f"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<link rel="stylesheet" href="./css/styles.css" type="text/css" />
    <link href="css/wyp.css" type="text/css" rel="stylesheet" />
    <style type="text/css">
        font {
            font-size: 14px;
        }
        
        hr {
            margin-left: 20%;
            width: 60%;
        }
        
        .lr {
            margin-top: 10px;
            float: left;
            width: 24%;
        }
        
        .cen {
            width: 52%;
            float: left;
        }
        
        .zxq {
            margin: 10px;
            float: left;
        }
        
        .xq {
            margin-top: 30px;
            float: left;
            width: 400px;
        }
        
        ul li {
            list-style: none;
            float: left;
        }
        
        .dh {
            margin-left: 22%;
        }
        
        div.zxq img {
            width: 400px;
            height: 300px;
        }
        
        .foot {
            text-align: center;
            width: 100%;
            line-height: 100px;
        }
        
        .reg {
            text-decoration: none;
            font-size: 8px;
            color: #006cff;
            float: left;
        }
        
        table {
            width: 100%;
            margin-top: 10px;
            font-size: 20px;
        }
        
        td {
            width: 30%;
        }
        
        .td1 {
            text-align: right;
        }
        
        .inp {
            line-height: 25px;
        }
        
        .btn {
            width: 81px;
            height: 30px;
        }
        
        .fie {
            width: 80%;
            text-align: center;
            margin-top: 20px;
            margin-left: 10%;
            height: 300px;
        }
        
        .leg {
            font-size: 18px;
            color: #657cdd;
        }
        
        .mt {
            width: 240px;
            height: 100px;
            margin-bottom: 10px;
            border: 1px solid #c4ccce;
        }
        .e{
        
        width: 200px;
        height: 240px;
        }
        .f{
       
         float:left;
   
}
 .d{
      
         float:right;
     
}
    </style>
    <script src="js/jquery.min.js"></script>
    <!--导航的js  -->
    <script src="js/lunbotu.js"></script>
    <script>
        <!--导航的js  -->
        $(function () {
            var lanren = $(".lanren a");
            lanren.click(function () {
                $(this).addClass("thisclass").siblings().removeClass("thisclass");
            });
        });
    </script>
</head>

<body leftMargin=0 topMargin=0 marginheight="0" marginwidth="0" onload="show()">
    <div class="tplb" style="width: 100%; height: 200px;">
        <div id="a1" style="background-image: url('images/1592.jpg'); background-size: 100% 100%; width: 100%; height: 100%"> </div>
        <div id="a2" class="dplay" style="background-image: url('images/0002.jpg'); background-size: 100% 100%; width: 100%; height: 100%"> </div>
        <div id="a3" class="dplay" style="background-image: url('images/1111.jpg'); background-size: 100% 100%; width: 100%; height: 100%"> </div>
    </div>
    <div class="lanren">
        <div class="dh">
            <ul>
                <li><a href="show.html">首页</a></li>
                <li><a href="details.html">网上订餐</a></li>
                <li><a href="shopCart.html">查看订单</a></li>
                <li><a href="checkout.html">订餐帮助</a></li>
                <li><a href="#">登录</a></li>
                <li><a href="#">注册</a></li>
                <li><a href="seeYou.html">在线客服</a></li>
            </ul>
        </div>
    </div>
    
    <table border="0" cellpadding="0" cellspacing="0"width="100%" height="100%">
<tr>
<td width="20%" height="100%">
<div class="f" ><img class="mt" src="images/mt.jpg"> <img src="images/mt1.jpg"></div>

</td>
<td rowspan="1" width="60%" height="100%">
<c:forEach var="i" items="${list}">
${i.img}<br>
${i.name}<br>
${i.originalPrtce}<br>
${i.currentPrtce }<br>
${i.material}<br>
<input type="submit" value="加入"></td>
</c:forEach>
</td>
<td width="20%" height="100%">
<div class="d"><img  src="images/mt3.jpg"></div>
</td>
</tr>
</table>
</body>
<%@ page language="java" contentType="text/html; charset=UTF-8" import="entity.*,java.util.*,dao.*,dao.impl.*"
    pageEncoding="UTF-8"%>
     <%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="f"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<link rel="stylesheet" href="./css/styles.css" type="text/css" />
    <link href="css/wyp.css" type="text/css" rel="stylesheet" />
    <style type="text/css">
        font {
            font-size: 14px;
        }
        
        hr {
            margin-left: 20%;
            width: 60%;
        }
        
        .lr {
            margin-top: 10px;
            float: left;
            width: 24%;
        }
        
        .cen {
            width: 52%;
            float: left;
        }
        
        .zxq {
            margin: 10px;
            float: left;
        }
        
        .xq {
            margin-top: 30px;
            float: left;
            width: 400px;
        }
        
        ul li {
            list-style: none;
            float: left;
        }
        
        .dh {
            margin-left: 22%;
        }
        
        div.zxq img {
            width: 400px;
            height: 300px;
        }
        
        .foot {
            text-align: center;
            width: 100%;
            line-height: 100px;
        }
        
        .reg {
            text-decoration: none;
            font-size: 8px;
            color: #006cff;
            float: left;
        }
        
        table {
            width: 100%;
            margin-top: 10px;
            font-size: 20px;
        }
        
        td {
            width: 30%;
        }
        
        .td1 {
            text-align: right;
        }
        
        .inp {
            line-height: 25px;
        }
        
        .btn {
            width: 81px;
            height: 30px;
        }
        
        .fie {
            width: 80%;
            text-align: center;
            margin-top: 20px;
            margin-left: 10%;
            height: 300px;
        }
        
        .leg {
            font-size: 18px;
            color: #657cdd;
        }
        
        .mt {
            width: 240px;
            height: 100px;
            margin-bottom: 10px;
            border: 1px solid #c4ccce;
        }
        .e{
        
        width: 200px;
        height: 240px;
        }
        .f{
       
         float:left;
   
}
 .d{
      
         float:right;
     
}
    </style>
    <script src="js/jquery.min.js"></script>
    <!--导航的js  -->
    <script src="js/lunbotu.js"></script>
    <script>
        <!--导航的js  -->
        $(function () {
            var lanren = $(".lanren a");
            lanren.click(function () {
                $(this).addClass("thisclass").siblings().removeClass("thisclass");
            });
        });
    </script>
</head>

<body leftMargin=0 topMargin=0 marginheight="0" marginwidth="0" onload="show()">
    <div class="tplb" style="width: 100%; height: 200px;">
        <div id="a1" style="background-image: url('images/1592.jpg'); background-size: 100% 100%; width: 100%; height: 100%"> </div>
        <div id="a2" class="dplay" style="background-image: url('images/0002.jpg'); background-size: 100% 100%; width: 100%; height: 100%"> </div>
        <div id="a3" class="dplay" style="background-image: url('images/1111.jpg'); background-size: 100% 100%; width: 100%; height: 100%"> </div>
    </div>
    <div class="lanren">
        <div class="dh">
            <ul>
                <li><a href="show.html">首页</a></li>
                <li><a href="details.html">网上订餐</a></li>
                <li><a href="shopCart.html">查看订单</a></li>
                <li><a href="checkout.html">订餐帮助</a></li>
                <li><a href="#">登录</a></li>
                <li><a href="#">注册</a></li>
                <li><a href="seeYou.html">在线客服</a></li>
            </ul>
        </div>
    </div>
    
    <table border="0" cellpadding="0" cellspacing="0"width="100%" height="100%">
<tr>
<td width="20%" height="100%">
<div class="f" ><img class="mt" src="images/mt.jpg"> <img src="images/mt1.jpg"></div>

</td>
<td rowspan="1" width="60%" height="100%">
<c:forEach var="i" items="${list}">
${i.img}<br>
${i.name}<br>
${i.originalPrtce}<br>
${i.currentPrtce }<br>
${i.material}<br>
<input type="submit" value="加入"></td>
</c:forEach>
</td>
<td width="20%" height="100%">
<div class="d"><img  src="images/mt3.jpg"></div>
</td>
</tr>
</table>
</body>

package servlet;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;


import dao.customerdao;
import dao.productdao;
import dao.impl.customerdaoimpl;
import dao.impl.productdaoimpl;
import entity.customer;

/**
 * Servlet implementation class loginservlet
 */
@WebServlet("/loginservlet")
public class loginservlet extends HttpServlet {
    private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public loginservlet() {
        super();
        // TODO Auto-generated constructor stub
    }

    /**
     * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
     */
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
         PrintWriter out=    response.getWriter();
            request.setCharacterEncoding("Utf-8");
            String uesrname=request.getParameter("username");
            String userpwd=request.getParameter("userpwd");
            customerdao dao=new customerdaoimpl();
            customer u=dao.login("uesrname", "userpwd");
            productdao pd=new productdaoimpl();
            ArrayList list=pd.f();
            HttpSession session=request.getSession();
            request.setAttribute("list", list);
            session.setAttribute("u", u);
            request.getRequestDispatcher("pro.jsp").forward(request, response);
            
    }

    /**
     * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
     */
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // TODO Auto-generated method stub
        doGet(request, response);
    }

}

img

  • 写回答

2条回答 默认 最新

  • 眰恦.H 2021-12-03 21:20
    关注

    ?号一般属于json乱码

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

问题事件

  • 系统已结题 12月16日
  • 已采纳回答 12月8日
  • 创建了问题 12月3日

悬赏问题

  • ¥15 有没有人会打学生成绩管理系统呀
  • ¥15 在使用Fiddler和夜神模拟器抓包的时候一直出现443该怎么办啊QAQ搜了好几个笔记都没有解决
  • ¥15 3x7的二维数组A、B、C,A中的任意1个数组元素与B的任意1个数组元素、同时又与C的任意1个数组元素比较,把不同位置出现相同数的比较称为无意义,反之称为有意义,把有意义的比较打印输出。
  • ¥20 预测模型怎么处理原始数据(随机森林)
  • ¥20 请问discuz3.5如何实现插入ckplayer全能播放器功能呢?
  • ¥15 thingsboard代码编译出错误
  • ¥15 博途v18仿真报错怎么解决
  • ¥15 欧姆龙plc枕式包装机 ST编程
  • ¥15 为啥快手广告联盟的广告这么难出来
  • ¥15 k8s集群重启后,kubelet一直报systemctl restart kubelet.service "Failed to delete cgroup paths"