老师,请求帮忙el表达式引用无效,是怎么回事
来源:2-5 导入Excel-3
twodogegg
2018-10-07 18:59:25
servlet页面
package org.imooc.servlet;
import org.apache.commons.fileupload.FileItem;
import org.apache.commons.fileupload.FileUploadException;
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
import org.apache.commons.fileupload.servlet.ServletFileUpload;
import org.imooc.dto.ImportExcelParamDto;
import org.imooc.dto.ImportExcelResultDto;
import org.imooc.dto.paramDto;
import org.imooc.service.ExcelService;
import org.imooc.util.RequestUtil;
import javax.servlet.ServletException;
import javax.servlet.ServletOutputStream;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.IOException;
import java.util.List;
@WebServlet(name = "IExcelServlet")
public class IExcelServlet extends HttpServlet {
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
System.out.println("111");
this.doGet(request,response);
}
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
System.out.println("222");
if(ServletFileUpload.isMultipartContent(request)){
paramDto dto = RequestUtil.parseParam(request);
ImportExcelParamDto paramDto = new ImportExcelParamDto();
paramDto.setTitle(dto.getParamMap().get("title"));
paramDto.setExcel(dto.getFileMap().get("excel"));
ExcelService service = new ExcelService();
ImportExcelResultDto resultDto = service.imp(paramDto);
request.setAttribute("result",resultDto);
}else{
//request.getParameter("");
}
request.getRequestDispatcher("/WEB-INF/jsp/importExcelResult.jsp").forward(request,response);
}
}
结果页面jsp
<td>${result.title}</td>--------就这一句这个el引用不对
jsp页面
<%--
Created by IntelliJ IDEA.
User: Administrator
Date: 2018\10\6 0006
Time: 22:05
To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jstl/core_rt" %>
<%@taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt_rt" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9; IE=8; IE=7; IE=EDGE"/>
<title></title>
<link rel="stylesheet" type="text/css" href="css/all.css"/>
<link rel="stylesheet" type="text/css" href="css/pop.css"/>
<link rel="stylesheet" type="text/css" href="css/main.css"/>
</head>
<body style="background: #e1e9eb;">
<form action="" id="mainForm" method="post">
<div class="right">
<div class="current">
当前位置:<a href="#">导入/导出</a> > 导入结果
</div>
<div class="rightCont">
<p class="g_title fix">导入结果展示</p>
<table class="tab1">
<tbody>
<tr>
<td align="right" width="80">标题:</td>
<td>${result.title}</td>
</tr>
</tbody>
</table>
<div class="zixun fix">
<table class="tab2" width="100%">
<tbody>
<tr>
<th>序号</th>
<th>姓名</th>
<th>年龄</th>
<th>出生日期</th>
</tr>
<!-- 通过varStatus,能直接从每一行取到状态比如说这里取到的是序号-->
<c:forEach items="${result.studentList}" var="item" varStatus="s" >
<tr>
<td>${s.count}</td>
<td>${item.name}</td>
<td>${item.age}</td>
<td><fmt:formatDate value="${item.time}" pattern="yyyy-mm-dd"></fmt:formatDate></td>
</tr>
</c:forEach>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</form>
</body>
</html>
2回答
twodogegg
提问者
2018-10-08
问题解决了,result里面的属性和产生result的类里面的属性名称写的不相符
twodogegg
提问者
2018-10-07
还有我刚测试了一下,所有EL和JSTL表达式都有问题
相似问题