我想将主机名和日期附加到日志文件名.所以日志文件名称应该像app_hostname.date.log. 注意:这应该在linux和windows中运行.
<appender name="applog" class="org.apache.log4j.DailyRollingFileAppender">
<param name="File" value="${path}/app.log" />
<param name="MaxFileSize" value="1MB" />
<param name="DatePattern" value=".dd-MM-yyyy" />
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="[%d{dd-MM-yyyy HH:mm:ss}] [%-5p] %m%n"/>
</layout>
</appender>
Run Code Online (Sandbox Code Playgroud)
以及如何根据日志模式添加过滤器,而不是StringMatchFilter
.我希望模式匹配.提前致谢
我读什么-是最内存消耗-的对象-在Java的的和什么-是最内存开销的-的对象-在Java的.
但我仍然感到困惑.
padding
吗?JVM
压缩指针?是reference
吗?32-bit JVM
使用,那么开销会减少?当然是.但是因为填充?32-bit JVM
使用内存效率或性能更好吗?下图来自此链接(第26页)
在这个图像开始时它们显示为16字节的JVM开销,为什么呢?
java jvm memory-management java-memory-model memory-overhead
我想在会话到期时获得会话超时消息.Below是我的spring-security.xml
<http auto-config="true" use-expressions="true">
<logout logout-success-url="/" invalidate-session="true" logout-url="/LogOut"/>
<form-login login-page="/Login" username-parameter="Name" password-parameter="Pwd"/>
<session-management invalid-session-url="/?timeout=true">
<concurrency-control max-sessions="1" expired-url="/Timeout?timeout=true" />
</session-management>
</http>
Run Code Online (Sandbox Code Playgroud)
根据我的知识,当会话到期时使用上面的代码它应该重定向到/?timeout=true OR /Timeout?timeout=true
.在退出时它应该去/
.但在我注销的情况下,它也会重定向到invalid-session-url
所以我总是在正常注销和会话超时时都超时.
请帮我区分一下.
UPDATE
/logout
请求包含
session = request.getSession();
session.invalidate();
session = null;
Run Code Online (Sandbox Code Playgroud) 我想将一些记录写入 excel 但我知道最大单元格样式XSSFWorkbook
是 64000。但是记录超过 64000 并考虑我想cellstyle
对每个单元格应用新的,否则我将使用现有的单元格样式进行克隆。
即使要克隆,我也需要采用默认的单元格样式, workbook.createCellStyle();
但这超过了 64001 条记录,导致java.lang.IllegalStateException: The maximum number of cell styles was exceeded.
.
那么无论如何在 POI 中是否知道已经存在特定的单元格样式并利用它或何时需要克隆/创建默认单元格样式和克隆。
克隆的原因是:有时列/行cellstyle
和 现有引用的 excel 单元格样式可能不同,因此我采用默认单元格样式并将 col & row & cell 克隆cellstyles
到它。
即使我尝试向地图添加默认样式,map.put("defStyle",workbook.createCellStyle();)
但这不会正确克隆,因为它会在第一次克隆尝试时发生变化,因为It wont get the Object it will copy the reference
即使对象克隆在这里也不可能,因为 cellstyle 没有实现cloneable interface
.
我已经gradle
从更新4.6
到6.1
,现在的问题是我在运行publishBootJavaPublicationToMavenRepository
任务时看不到詹金斯控制台上打印的任何信息。
在执行此任务之前,您会看到类似的内容Upload: http://nexusblabla.war
,但现在此任务没有打印任何内容。
这是我的javascript代码:
function getLocation() {
//navigator.geolocation.getCurrentPosition(getCoor, errorCoor, {maximumAge:60000, timeout:30000, enableHighAccuracy:true});
var mobile =jQuery.browser.mobile;
var deviceAgent = navigator.userAgent.toLowerCase();
var agentID = deviceAgent.match(/(iphone|ipod|ipad)/);
if(mobile){
watchLocation(function(coords) {
var latlon = coords.latitude + ',' + coords.longitude;
//some stuff
}, function() {
alert("error");
});
} else {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(showPosition);
} else {
alert("error");
}
}
}
function watchLocation(successCallback, errorCallback) {
successCallback = successCallback || function(){};
errorCallback = errorCallback || function(){};
// Try HTML5-spec geolocation.
var geolocation = navigator.geolocation;
if (geolocation) {
// We have …
Run Code Online (Sandbox Code Playgroud) public static void main( String... args){
int a = 5 - '0';
System.out.println(a); //-43
Integer b = 5 - '0';
System.out.println(b); //-43
System.out.println(Integer.valueOf(a)); //-43
System.out.println(String.valueOf(b)); //-43
}
Run Code Online (Sandbox Code Playgroud)
所以我对这段代码有两个问题.
int=5-'0';
可能?5
是一个可以正常的int,但旁边是一个字符,而不是为什么它不会抛出任何错误?我知道ASCII值43
是,+
但它会转换'0'
为它的ASCII然后进行操作吗?
我的Web应用程序使用spring security在登录时对用户进行身份验证.我还有并发控制,以避免用户在不同的机器上登录两次.这工作正常但我的问题是:如果用户登录计算机,则关闭浏览器.然后他重新打开网络应用程序,尝试再次登录,他获得以下消息:"超出此主数的最大会话数为1".我想在浏览器关闭时使会话无效.我怎样才能做到这一点?
弹簧security.xml文件
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://. www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/. XMLSchema-instance" xmlns:security="http://www.springframework.org/schema/security"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/security
http://www.springframework.org/schema/security/. spring-security-3.1.xsd">
<security:global-method-security
secured-annotations="enabled" />
<security:http auto-config="false"
authentication-manager-ref="authenticationManager" use-expressions="true">
<!-- Override default login and logout pages -->
<security:form-login
authentication-failure-handler-ref="fail"
authentication-success-handler-ref="success" login-page="/car/login.xhtml"
default-target-url="/jsf/car/home.xhtml" />
<security:logout invalidate-session="true"
logout-url="/j_spring_security_logout" success-handler-ref="customLogoutHandler" delete-cookies="JSESSIONID"/>
<security:session-management>
<security:concurrency-control
max-sessions="1" error-if-maximum-exceeded="true" />
</security:session-management>
<security:intercept-url pattern="/jsf/**"
access="isAuthenticated()" />
<security:intercept-url pattern="/run**"
access="isAuthenticated()" />
<security:intercept-url pattern="/pages/login.xhtml"
access="permitAll" />
</security:http>
<bean id="success" class="com.car.LoginSuccess" />
<bean id="fail" class="com.car.LoginFailed">
<property name="defaultFailureUrl" value="/?login_error=true" />
</bean>
<bean id="passwordEncoder"
class="org.springframework.security.authentication.encoding.ShaPasswordEncoder" />
<security:authentication-manager alias="authenticationManager"> …
Run Code Online (Sandbox Code Playgroud) 我认为不需要多解释,为什么以下计算结果为1?
int a = 2147483647;
int b = 2147483647;
int c = a * b;
long d = a * b;
double e = a * b;
System.out.println(c); //1
System.out.println(d); //1
System.out.println(e); //1.0
Run Code Online (Sandbox Code Playgroud) java ×8
android ×1
apache-poi ×1
build ×1
excel ×1
geolocation ×1
gradle ×1
html5 ×1
int ×1
javascript ×1
jenkins ×1
jsf-2 ×1
jvm ×1
log4j ×1
logfile ×1
logging ×1
session ×1
spring ×1
spring-boot ×1
spring-mvc ×1