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日

悬赏问题

  • ¥20 wireshark抓不到vlan
  • ¥20 关于#stm32#的问题:需要指导自动酸碱滴定仪的原理图程序代码及仿真
  • ¥20 设计一款异域新娘的视频相亲软件需要哪些技术支持
  • ¥15 stata安慰剂检验作图但是真实值不出现在图上
  • ¥15 c程序不知道为什么得不到结果
  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来