@Configurationpublic class CorsConfig {/*** 允许跨域调用的过滤器*/@Beanpublic CorsFilter corsFilter() {CorsConfiguration config = new CorsConfiguration();// 允许跨越发送cookieconfig.setAllowCredentials(true);// 允许所有域名进行跨域调用config.addAllowedOrigin("*");// 放行全部原始头信息config.addAllowedHeader("*");// 允许所有请求方法跨域调用config.addAllowedMethod("*");UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();source.registerCorsConfiguration("/**", config);return new CorsFilter(source);}}
private Class<T> entityClass = (Class<T>) ((ParameterizedType) getClass().getGenericSuperclass()).getActualTypeArguments()[0];
通过反射打印对象:
System.out.println(ReflectionToStringBuilder.toString(umsAdmin, ToStringStyle.MULTI_LINE_STYLE));
line = bufferedReader.readLine()) != null
先赋值再比较,然后就可以使用变量输出 System.out.println(line);
,不需要执行两次 bufferedReader.readLine()
。
String line;while ((line = bufferedReader.readLine()) != null) {System.out.println(line);}
private Date convertTime(Date date) {Calendar calendar = Calendar.getInstance();calendar.setTime(date);calendar.set(Calendar.MINUTE, 0);calendar.set(Calendar.SECOND, 0);calendar.set(Calendar.MILLISECOND, 0);return calendar.getTime();}
@GetMapping("{id}")public String reg(HttpServletRequest request, @PathVariable long id) {System.out.println("url" + request.getRequestURI());TbUser tbUser = tbUserMapper.selectByPrimaryKey(id);return tbUser.getUsername();}
HashMap<String, OrderAmount> OrderAmountHashMap = new HashMap<>();List<String> axis = OrderAmountHashMap.keySet().stream().sorted().collect(Collectors.toList());List<OrderAmount> list = new ArrayList<OrderAmount>(OrderAmountHashMap.values());
List<Date> dateList = getDateListOfDay();List<String> axis = IntStream.range(0, dateList.size()).mapToObj(i -> DateFormat.format(dateList.get(i))).collect(Collectors.toList());
InputStream stream = FileUtil.class.getClassLoader().getResourceAsStream("media/" + mobileconfig);File targetFile = new File("media/" + System.currentTimeMillis() + ".mobileconfig");FileUtils.copyInputStreamToFile(stream, targetFile);return targetFile;
private static File template() {Map<String, String> map = new HashMap<>();map.put("image_url", imageUrl);map.put("app_name", appName);map.put("official_url", officialUrl);InputStream stream = FileUtil.class.getClassLoader().getResourceAsStream("media/" + mobileconfig);File targetFile = new File("media/" + System.currentTimeMillis() + ".mobileconfig");StringSubstitutor sub = new StringSubstitutor(map);try {Reader fr = new InputStreamReader(stream);BufferedReader reader = new BufferedReader(fr);FileWriter fw = new FileWriter(target);BufferedWriter writer = new BufferedWriter(fw);String str;while ((str = reader.readLine()) != null) {String newStr = sub.replace(str);writer.write(newStr);writer.newLine();}writer.flush();writer.close();} catch (Exception e) {e.printStackTrace();}return target;}