跨域获取cookie失效解决方案
参考:http://www.bubuko.com/infodetail-357996.html
1、iphone 自带浏览器(Safari)跨网站跟踪时,需要关闭Safari设置中"阻止跨网站跟踪",如下图:
2、iphone 中firefox 以及Google Chrome浏览器由于涉及到用户隐私,默认时关闭
由于以上2点,自定义Session
请求时需带参数token,示例:
http://localhost:8080/test/info?token=12345678
Locale locale = new Locale("en", "US");
ActionContextUtil.getContext(token).getSession().put(Constants.WW_TRANS_I18N_LOCALE, locale);
String themeName = "default";
ActionContextUtil.getContext(token).getSession().put(Constants.SESSION_KEY_THEME_NAME, themeName);
ActionContextUtil.getContext(token).setCustomI18N();
ActionContextUtil.getContext(token).setThemeName();
配置文件config.properties
#定时任务周期(单位:毫秒):1分钟 = 1000*60
periodTime=60000
#自定义session超时时间(单位:毫秒):30分钟 = 1000*60*30
sessionTimeout=300000
web.xml 配置监听器
<listener>
<listener-class>cn.ding.listener.ServiceDataTaskListener</listener-class>
</listener>
创建监听器
package cn.ding.listener;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import org.apache.log4j.Logger;
import cn.co.test.task.TimerManager;
public class ServiceDataTaskListener implements ServletContextListener {
private static Logger logger = Logger.getLogger(ServiceDataTaskListener.class);
@Override
public void contextInitialized(ServletContextEvent sce) {
try {
new TimerManager();
} catch (Exception e) {
logger.error(e);
}
}
@Override
public void contextDestroyed(ServletContextEvent sce) {
}
}
定时