Access-Control-Expose-Headers: X-Auth-Token

import org.apache.cxf.rs.security.cors.CrossOriginResourceSharingFilter;
...
	@Bean
	public CrossOriginResourceSharingFilter crossOriginResourceSharingFilter() {
		final CrossOriginResourceSharingFilter corsf = new CrossOriginResourceSharingFilter();
		final List<String> exposeHeaders = new ArrayList<>(corsf.getExposeHeaders());
		exposeHeaders.add("X-Auth-Token");
		log.debug("exposeHeaders: {}", String.join(", ", exposeHeaders));
		corsf.setExposeHeaders(exposeHeaders);
		return corsf;
	}
...

See also:
https://developer.mozilla.org/en-US/docs/Web/HTTP/Access_control_CORS#Access-Control-Expose-Headers
http://cxf.apache.org/docs/jax-rs-cors.html

#apache-cxf, #cors, #java, #jax-rs, #spring-boot, #spring-session

利用动态 bean 实现 display tag 不定列数

<!DOCTYPE html>
 <%@page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"
 import="
 java.util.List,
 java.util.ArrayList,
 java.util.Calendar,
 java.util.Random,
 java.text.DateFormat,
 java.text.SimpleDateFormat,
 org.apache.commons.beanutils.DynaProperty,
 org.apache.commons.beanutils.DynaClass,
 org.apache.commons.beanutils.DynaBean,
 org.apache.commons.beanutils.BasicDynaClass"%>
 <%@ taglib uri="http://displaytag.sf.net" prefix="display" %>
 <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
 <%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
 <%
 // Categories
 List<String> categories = new ArrayList<String>();
 categories.add("分类1");
 categories.add("分类2");
 categories.add("分类3");
 categories.add("分类4");
 categories.add("分类5");
 
 // Properties
 List<DynaProperty> properties = new ArrayList<DynaProperty>();
 properties.add(new DynaProperty("date"));
 for (String category : categories) {
 properties.add(new DynaProperty(category));
 }
 
 // Class
 DynaClass tableDataClass = new BasicDynaClass("tableData", null, properties.toArray(new DynaProperty[0]));
 
 // Table data
 List<DynaBean> tableData = new ArrayList<DynaBean>();
 
 DateFormat df = new SimpleDateFormat("yyyy/MM/dd");
 Calendar begin = Calendar.getInstance();
 begin.setTime(df.parse("2011/07/23"));
 Calendar end = Calendar.getInstance();
 end.setTime(df.parse("2011/08/01"));
 int groupField = Calendar.DATE;
 
 for (Calendar current = (Calendar) begin.clone(); !current.after(end); current
 .add(groupField, 1)) {
 // New an instance
 DynaBean tableDataBean = tableDataClass.newInstance();
 
 // Set properties
 tableDataBean.set("date", current.getTime());
 for (String category : categories) {
 tableDataBean.set(category, new Random().nextInt(1000));
 }
 
 // Add to list
 tableData.add(tableDataBean);
 }
 
 // Save to page context
 pageContext.setAttribute("categories", categories);
 pageContext.setAttribute("tableData", tableData);
 %>
 <html>
 <head>
 <meta charset="UTF-8">
 <title>Display tag 不定列数示例</title>
 </head>
 <body>
 <display:table list="${tableData}" id="tableDatum">
 <display:column property="date" format="{0,date,yyyy-MM-dd}" title="日期" />
 <c:forEach items="${categories}" var="category">
 <display:column property="${category}" /></c:forEach>
 </display:table>
 
 <ul>
 <li><a href="http://www.displaytag.org/1.2/index.html">Display tag library 1.2</a></li>
 <li><a href="http://commons.apache.org/beanutils/">Commons BeanUtils</a></li>
 </ul>
 </body>
 </html>

效果图:

#commons-beanutils, #display-tag, #java