我有String Standard应用程序(无引导)并使用var express = require('express');
var app = express();
app.get('/', function (req, res) {
const subdomain = req.headers.subdomain;
});
app.listen(3000, function () {
console.log('Example app listening on port 4000!');
});
存储会话i数据库。
然而,会话存储在没有@EnableJdbcHttpSession
列的数据库中,该列为NULL,也在我的index.jsp页面PRINCIPAL_NAME
上为空。当我没有${sessionScope.SPRING_SECURITY_CONTEXT.authentication.principal}
注释时,我的主要用户被正确写入。
在我的@EnableJdbcHttpSession
中:
pom.xml
我还有 <dependency>
<groupId>org.springframework.session</groupId>
<artifactId>spring-session</artifactId>
<version>1.3.2.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.session</groupId>
<artifactId>spring-session-core</artifactId>
<version>2.0.2.RELEASE</version>
</dependency>
的数据源类:
@EnableJdbcHttpSession
并且分别为三个初始化类:
@EnableTransactionManagement
@EnableJdbcHttpSession
public class Datasource{
@Autowired
private AppEnvironment env;
@Bean(name = "dataSource")
public DataSource dataSource() {
BasicDataSource dataSource = new BasicDataSource();
dataSource.setDriverClassName(env.getDriverClassName());
dataSource.setUrl(env.getDatabaseUrl());
dataSource.setUsername(env.getDatabaseUserName());
dataSource.setPassword(env.getDatabasePassword());
dataSource.setValidationQuery(env.getDatabaseValidationQuery());
dataSource.setTestOnBorrow(env.isTomcatTestOnBorrow());
return dataSource;
}
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
HibernateJpaVendorAdapter jpaAdapter = new HibernateJpaVendorAdapter();
jpaAdapter.setShowSql(Boolean.valueOf(env.isJpaShowSql()));
jpaAdapter.setDatabase(Database.SQL_SERVER);
LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean();
em.setPersistenceProvider(new HibernatePersistenceProvider());
em.setDataSource(dataSource());
em.setPackagesToScan(new String[] { "com.humanbizz.web.entities" });
em.setPersistenceUnitName("persistenceUnit");
em.setJpaVendorAdapter(jpaAdapter);
em.setJpaProperties(additionalProperties());
return em;
}
@Bean
public JpaTransactionManager transactionManager() {
JpaTransactionManager transactionManager = new JpaTransactionManager();
transactionManager.setEntityManagerFactory(entityManagerFactory().getObject());
return transactionManager;
}
Properties additionalProperties() {
Properties properties = new Properties();
properties.setProperty("hibernate.dialect", env.getHibernateDialect());
properties.setProperty("hibernate.default_catalog", env.getDefaultCatalog());
properties.setProperty("hibernate.hbm2ddl.auto", env.getHbm2ddlAuto());
properties.setProperty("hibernate.id.new_generator_mappings", String.valueOf(env.isIdNewGeneratorMappings()));
properties.setProperty("hibernate.default_schema", env.getDefaultSchema());
properties.setProperty("hibernate.connection.useUnicode", String.valueOf(env.isConnectionUseUnicode()));
properties.setProperty("hibernate.connection.charSet", env.getConnectionCharSet());
return properties;
}
}
和
@Order(1)
public class DispatcherServletInitializer extends AbstractAnnotationConfigDispatcherServletInitializer {
@Override
protected Class<?>[] getRootConfigClasses() {
return new Class[] { Datasource.class, WebSecurity.class};
}
@Override
protected Class<?>[] getServletConfigClasses() {
return new Class[] { WebMvc.class };
}
@Override
protected String[] getServletMappings() {
return new String[]{"/"};
}
}
和
@Order(2)
public class SecurityInitializer extends AbstractSecurityWebApplicationInitializer {
}
某处@Order(3)
public class SpringSessionInicializer extends AbstractHttpSessionApplicationInitializer {
}
覆盖JdbcSession
,但我不知道在哪里以及如何解决这个问题,如果有人知道如何解决这个问题,欢迎我,谢谢