‘壹’ java 镐庝箞璁剧疆request镄删ead
姝ラゅ备笅锛
1銆佸湪web宸ョ▼閲岄溃鍒涘缓涓涓猄ervlet绫伙纴缁ф圹HttpServlet锛岄吨鍐檇oPost,doGet鏂规硶锛屽湪doPost鏂规硶涓璋幂敤doGet鏂规硶锛
2銆佸湪doGet鏂规硶涓鎶婅佽剧疆鍒癹sp椤甸溃镄勫煎瓨鍒皉equest涓锛
3銆佸湪doGet鏂规硶涓娣诲姞杞鍙戝埌jsp椤甸溃镄勪唬镰侊绂
4銆佸湪jsp椤甸溃涓浣跨敤jstl镙囩捐幏鍙栧瓨鍏ョ殑鍊笺
浜嬩緥浠g爜濡备笅锛
Servlet绫伙细
public class DemoServlet extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
request.setAttribute("name", "nameValue");
request.getRequestDispatcher("/demo.jsp").forward(request, response);
}
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
doGet(request, response);
}
}
jsp椤甸溃锛
<%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Demo</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
</head>
<body>
${name }
</body>
</html>
鍏朵腑锛<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>琛ㄧず瀵煎叆jstl镙囩惧簱锛屾病瀵煎叆镄勮瘽镞犳硶浣跨敤jstl镙囩撅纴浣跨敤jstl镙囩惧彲浠ュ噺灏戝緢澶氢唬镰侀噺锛屽煎叆jstl镙囩惧悗灏卞彲浠ラ氲繃浣跨敤${}镄勬柟娉曟潵銮峰彇鍊间简銆
‘贰’ Java 如何设置被导出excel单元格的样式比如背景色,大小什么的
使用 poi ,具体实现
HSSFCellStyle style = null;
// 创建表头style
HSSFCellStyle cellStyleTitle = workbook.createCellStyle();
cellStyleTitle.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND); // 填充单元格
cellStyleTitle.setFillForegroundColor(HSSFColor.YELLOW.index);
cellStyleTitle.setAlignment(HSSFCellStyle.ALIGN_CENTER);// //居中显示
HSSFRow titleRow = sheet.createRow(0);
for (int i = 0; i < titles.length; i++) {
HSSFCell cell = titleRow.createCell(i);
// cell.setCellStyle(createCellColorStyle(workbook));
cell.setCellStyle(cellStyleTitle);
cell.setCellValue(titles[i]);// 给单元格赋值
}
不知道能,看懂不,如果有不清楚的私聊