123456147% 2021-12-03 12: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 13:20
    关注

    ?号一般属于json乱码

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

报告相同问题?

问题事件

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

悬赏问题

  • ¥20 校园网认证openwrt插件
  • ¥15 以AT89C51单片机芯片为核心来制作一个简易计算器,外部由4*4矩阵键盘和一个LCD1602字符型液晶显示屏构成,内部由一块AT89C51单片机构成,通过软件编程可实现简单加减乘除。
  • ¥15 某东JD算法逆向算法
  • ¥15 求GCMS辅导数据分析
  • ¥30 SD中的一段Unet下采样代码其中的resnet是谁跟谁进行残差连接
  • ¥15 Unet采样阶段的res_samples问题
  • ¥60 Python+pygame坦克大战游戏开发实验报告
  • ¥15 R语言regionNames()和demomap()无法选中中文地区的问题
  • ¥15 Open GL ES 的使用
  • ¥15 我如果只想表示节点的结构信息,使用GCN方法不进行训练可以吗
手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部