iframe嵌套的list.jsp页面出现乱码
ManagementController.java
package com.imooc.magllery.controller;
import java.io.IOException;
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 com.imooc.magllery.service.PaintingService;
import com.imooc.magllery.utils.PageModel;
/**
* 后台管理功能Controller
*/
@WebServlet("/management")
public class ManagementController extends HttpServlet {
private PaintingService paintingService = new PaintingService();
private static final long serialVersionUID = 1L;
/**
* @see HttpServlet#HttpServlet()
*/
public ManagementController() {
super();
// TODO Auto-generated constructor stub
}
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
request.setCharacterEncoding( "UTF-8" );
response.setContentType( "text/html;charset=utf-8");
String method = request.getParameter( "method" );
if( method.equals( "list" ) ) {
this.list( 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);
}
private void list (HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException{
//接收参数,p页数,r行数
String p = request.getParameter( "p" );
String r = request.getParameter( "r" );
if( p == null ) {
p = "1";
}
if( r == null ) {
r = "6";
}
PageModel pageModel = paintingService.pagination( Integer.parseInt( p ), Integer.parseInt( r ) );
request.setAttribute( "pageModel", pageModel );
request.getRequestDispatcher( "/WEB-INF/jsp/list.jsp" ).forward(request, response);
}
}list.jsp
<%@page contentType = "text/html;charset = utf-8"%>
<%@taglib uri = "http://java.sun.com/jsp/jstl/core" prefix = "c" %>
<%@taglib uri = "http://java.sun.com/jsp/jstl/fmt" prefix = "fmt" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>油画列表</title>
<link rel="stylesheet" type="text/css" href="css\list.css">
</head>
<body>
<div class="container">
<fieldset>
<legend>油画列表</legend>
<div style="height: 40px">
<a href="#" class="btn-button">新增</a>
</div>
<!-- 油画列表 -->
<table cellspacing="0px">
<thead>
<tr style="width: 150px;">
<th style="width: 100px">分类</th>
<th style="width: 150px;">名称</th>
<th style="width: 100px;">价格</th>
<th style="width: 400px">描述</th>
<th style="width: 100px">操作</th>
</tr>
</thead>
<c:forEach items = "${pageModel.pageData }" var = "painting">
<tr>
<td>
<c:choose>
<c:when test = "${painting.categroy == 1 }">
现实主义
</c:when>
<c:when test = "${painting.categroy == 2 }">
抽象主义
</c:when>
<c:otherwise>
位置的类型
</c:otherwise>
</c:choose>
</td>
<td>${painting.pname }</td>
<td><fmt:formatNumber pattern = "¥0.00" value = "${painting.price }"></fmt:formatNumber></td>
<td>${painting.description }</td>
<td>
<a class="oplink" href="#">预览</a>
<a class="oplink" href="#">修改</a>
<a class="oplink" href="#">删除</a>
</td>
</tr>
</c:forEach>
</table>
<!-- 分页组件 -->
<ul class="page">
<li><a href="#">首页</a></li>
<li><a href="#">上页</a></li>
<li class='active'><a href="#">1</a></li>
<li ><a href="#">2</a></li>
<li><a href="#">下页</a></li>
<li><a href="#">尾页</a></li>
</ul>
</fieldset>
</div>
</body>
</html>36
收起
正在回答 回答被采纳积分+1
3回答
java工程师2020版
- 参与学习 人
- 提交作业 9410 份
- 解答问题 16556 个
综合就业常年第一,编程排行常年霸榜,无需脱产即可学习,北上广深月薪过万 无论你是未就业的学生还是想转行的在职人员,不需要基础,只要你有梦想,想高薪
了解课程




恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧
0 星