我使用remember-me选项配置了Spring Security.
<security:global-method-security secured-annotations="enabled" />
<security:http pattern="/login.html" security="none"/>
<security:http pattern="/signup.html" security="none"/>
<security:http pattern="/scripts/**" security="none"/>
<security:http pattern="/styles/**" security="none"/>
<security:http pattern="/images/**" security="none"/>
<security:http disable-url-rewriting="true" access-denied-page="/accessDenied.jsp">
<security:session-management>
<security:concurrency-control error-if-maximum-exceeded="false" max-sessions="10"/>
</security:session-management>
<security:form-login login-page="/login.html" login-processing-url="/login" authentication-failure-url="/login.html?login_error=1" default-target-url="/"/>
<security:intercept-url pattern='/**' access='ROLE_USER' />
<security:logout logout-url="/logout" logout-success-url="/"/>
<security:remember-me services-ref="rememberMeServices" />
</security:http>
Run Code Online (Sandbox Code Playgroud)
然后是服务本身:
<bean id="rememberMeServices" class="org.springframework.security.web.authentication.rememberme.PersistentTokenBasedRememberMeServices">
<property name="tokenRepository" ref="myTokenRepository" />
<property name="userDetailsService" ref="userDetailsService" />
<property name="key" value="myRememberMeKey" />
<property name="alwaysRemember" value="true" />
</bean>
<bean id="myTokenRepository" class="com.mytwitter.web.security.MyTokenRepository">
</bean>
Run Code Online (Sandbox Code Playgroud)
我可以在我的架构中看到在数据库中插入/更新/删除令牌.所以这不是问题.
但登录失败:
2012-02-13 13:35:56,497 DEBUG [http-bio-8080-exec-5] org.springframework.security.web.authentication.rememberme.PersistentTokenBasedRememberMeServices - Remember-me cookie detected …Run Code Online (Sandbox Code Playgroud) 我有下面的表名为Order
Orders Table
___________________________________________________
orderiD | userId | OrderType | Order_Date | Amount
________|________|___________|____________|________
1 1 0 12/12/2009 1
2 1 1 13/12/2009 2
3 1 1 14/12/2009 3
4 2 0 12/12/2009 4
5 2 1 16/12/2009 2
6 1 0 14/12/2009 5
7 2 1 17/12/2009 4
8 2 0 10/12/2010 2
___________________________________________________
Run Code Online (Sandbox Code Playgroud)
我需要创建一个返回最大购买商数量的用户ID的查询.
我尝试了以下内容
Select MAX(GRP.sumAmmount), o.userId join
(Select SUM(o.Amount) as sum_ammount, o.userId as UID from Orders GROUP BY(o.userID)) as GRP on o.userId=GRP.UID GROUP BY(GRP.UID)
Run Code Online (Sandbox Code Playgroud)
但我相信我错过了一些东西.
你能帮我吗?
我只是无法理解为什么我的读取时间不起作用.我想要做的就是等待
10秒钟让某个线程将消息发送到,BlockedQueue<String>并在超时时返回客户端上的某种响应.
public class NioAsynChatPipelineFactory implements ChannelPipelineFactory {
private static Timer timer = new HashedWheelTimer();
private final ChannelHandler timeoutHandler = new ReadTimeoutHandler(timer, 10);
@Override
public ChannelPipeline getPipeline() throws Exception {
ChannelPipeline pipeline = Channels.pipeline();
pipeline.addLast("decoder", new HttpRequestDecoder());
pipeline.addLast("encoder", new HttpResponseEncoder());
pipeline.addLast("handler", new NioAsynChatHandler());
pipeline.addLast("timeout", this.timeoutHandler);
return pipeline;
}
}
Run Code Online (Sandbox Code Playgroud)
现在我的处理程序看起来像这样
public class NioAsynChatHandler extends SimpleChannelUpstreamHandler{
@Override
public void handleUpstream(
ChannelHandlerContext ctx, ChannelEvent e) throws Exception {
super.handleUpstream(ctx, e);
}
@Override
public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e)
throws Exception …Run Code Online (Sandbox Code Playgroud) 让我们考虑一下我有一些具有B类属性的A类.
public class ClassA{
private ClassB classB;
public ClassA(ClassB classB){
this.classB = classB;
}
//some methods ommitted.
}
Run Code Online (Sandbox Code Playgroud)
不,我有CGLIB代理:
public class CGLibProxy implements MethodInterceptor{
@Override
public Object intercept(Object object, Method method, Object[] args,
MethodProxy methodProxy) throws Throwable {
if (method.getName().startsWith("print")){
System.out.println("We will not run any method started with print");
return null;
}
else
return methodProxy.invokeSuper(object, args);
}
}
Run Code Online (Sandbox Code Playgroud)
现在,当我CGLib用于ClassA时,代理会创建ClassA实例.
我的问题是如何将classB参数传递给此代理,因为据我所知,CGLib将为ClassA运行空构造函数?
我有两个函数将日期字符串转换为以毫秒为单位的日期:
public static long convertYYYYMMDDtoLong(String date) throws ParseException {
SimpleDateFormat f = new SimpleDateFormat("yyyy-mm-dd");
Date d = f.parse(date);
long milliseconds = d.getTime();
return milliseconds;
}
Run Code Online (Sandbox Code Playgroud)
如果我运行此函数,我会得到以下结果:
long timeStamp = convertYYYYMMDDtoLong("2014-02-17");
System.out.println(timeStamp);
Run Code Online (Sandbox Code Playgroud)
它打印:
1389909720000
Run Code Online (Sandbox Code Playgroud)
现在,如果我运行以下代码:
Calendar cal = Calendar.getInstance();
cal.setTimeInMillis(timeStamp);
System.out.println(cal.getTime());
Run Code Online (Sandbox Code Playgroud)
打印出来:
Fri Jan 17 00:02:00 IST 2014
Run Code Online (Sandbox Code Playgroud)
为什么我的约会时间转移了一个月?怎么了?
PS:我的问题是我需要将日期(表示为)映射long到另一个Calendar仅接受格式的第三方API .