『壹』 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]);// 給單元格賦值
}
不知道能,看懂不,如果有不清楚的私聊