SpringMVC5页面

dxxyhpgq  于 2021-10-10  发布在  Java
关注(0)|答案(0)|浏览(166)

web.xml

<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd" version="4.0"> 
<display-name>EST</display-name>
<description>EST Portal</description>

<servlet-name>dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>

<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/dispatcher-servlet.xml, /WEB-INF/spring-security.xml</param-value> 
</context-param>

<servlet-mapping>
<servlet-name>dispatcher</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping> 

<servlet>
<servlet-name>RptDownload</servlet-name>
<servlet-class>com.est.utils.RptDownload</servlet-class>
</servlet>

<servlet>
<servlet-name>InvView</servlet-name>
<servlet-class>com.est.utils.InvView</servlet-class>
<load-on-startup>2</load-on-startup>
</servlet>

<servlet-mapping>
<servlet-name>InvView</servlet-name> 
<url-pattern>/InvView</url-pattern>
</servlet-mapping>

<servlet-mapping>
<servlet-name>RptDownload</servlet-name>
<url-pattern>/RptDownload</url-pattern>
</servlet-mapping>

<error-page>
<error-code>404</error-code>
<location>/pages/commonerror.jsp</location>
</error-page>

<error-page>
<error-code>403</error-code>
<location>/pages/commonerror.jsp</location>
</error-page>

<error-page>
<exception-type>java.lang.Exception</exception-type> 
<location>/pages/commonerror.jsp</location>
</error-page>

<context-param>
<param-name>defaultHtmlEscape</param-name>
<param-value>true</param-value>
</context-param>
<servlet>

<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

<listener>
<listener-class>com.est.filter.CustomHttpSessionListener</listener-class> 
</listener>

<listener>
<listener-class>org.springframework.security.web.session.HttpSessionEventPublisher</listener-class>
</listener>

<listener>
<listener-class>com.est.web.CleanUpSessionListener</listener-class>
</listener>

<filter>
<filter-name>springSecurityFilterChain</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>

<filter-mapping>
<filter-name>springSecurityFilterChain</filter-name> 
<url-pattern>/*</url-pattern>
</filter-mapping>

<session-config>
<session-timeout>30</session-timeout>
</session-config>

<listener>
<listener-class>org.springframework.security.web.session.HttpSessionEventPublisher</listener-class>
</listener>

</web-app>

spring-security.xml

<beans:beans xmlns="http://www.springframework.org/schema/security" 
xmlns:beans="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
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.xsd">

<http pattern="/resource/**" security="none" />
<http entry-point-ref="loginUrlAuthenticationEntryPoint" use-expressions="true"> 
<intercept-url pattern="/web/**" access="permitAll" />
<intercept-url pattern="/j_spring security_check" access="isAnonymous()" /> 
<intercept-url pattern="/web/j_spring security_check" access="isAnonymous()" /> <intercept-url pattern="/**" access="hasAnyRole('USER_ADMINISTRATION', 'IT_SUPPORT')" />
<logout success-handler-ref="CustomLogoutHandler" invalidate-session="true" delete-cookies="JSESSIONID" />
<access-denied-handler error-page="/web/Default.html" /> 

<custom-filter position="CONCURRENT_SESSION_FILTER" ref="concurrencyFilter" /> 
<custom-filter position="FORM_LOGIN_FILTER" ref="myAuthFilter"/> 
<custom-filter position="LAST" ref="appFilter" />
<session-management session-authentication strategy-ref="sas" invalid-session-url="/web/Auth.html" /> 
</http>

    <authentication-manager alias="authenticationManager"> 
    <authentication-provider ref="CustomAuthenticationProvider"/>
    </authentication-manager>

    <beans:bean id="springSecurityFilterChain" class="org.springframework.web.filter.DelegatingFilterProxy"/>
    <beans:bean id="CustomLogoutHandler" class="com.test.authentication.CustomLogoutHandler"/>
    <beans:bean id="CustomAuthenticationProvider" class="com.test.authentication.CustomAuthenticationProvider"/>
    <beans:bean id="customAuthenticationSuccessHandler" class="com.test.authentication.CustomAuthenticationSuccessHandler"/> 
    <beans:bean id="appFilter" class="com.test.asg.filter.ApplicationFilter"/>
    <beans:bean id="customAuthenticationFailureHandler" class="com.test.authentication.CustomAuthenticationFailureHandler"/>

    <beans:bean id="redirectSessionInformationExpiredStrategy" class="org.springframework.security.web.session.SimpleRedirectSessionInformationExpiredStrategy">
       <beans:constructor-arg name="invalidSessionUrl" value="/web/Default.html" />
    </beans:bean>

    <beans:bean id="concurrencyFilter" class="org.springframework.security.web.session.ConcurrentSessionFilter">
    <beans:constructor-arg name="sessionRegistry" ref="sessionRegistry" /> 
    <beans:constructor-arg name="sessionInformationExpiredStrategy" ref="redirectSessionInformationExpiredStrategy" />
    </beans:bean>

    <beans:bean id="myAuthFilter" class="org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter">
    <beans:property name="sessionAuthenticationStrategy" ref="sas" /> 
    <beans:property name="authenticationManager" ref="authenticationManager" />
    <beans:property name="authenticationFailureHandler" ref="customAuthenticationFailureHandler"/> 
    <beans:property name="authenticationSuccessHandler" ref="customAuthenticationSuccessHandler"/>
    <beans:property name="usernameParameter" value="username"/>
    <beans:property name="passwordParameter" value="password"/>
    </beans:bean>

<beans:bean id="sas" class="org.springframework.security.web.authentication.session.CompositeSessionAuthenticationStrategy">
<beans:constructor-arg>
    <beans:list>

        <beans:bean class="org.springframework.security.web.authentication.session.ConcurrentSessionControlAuthenticationStrategy">
        <beans:constructor-arg ref="sessionRegistry"/>
        <beans:property name="maximumSessions" value="1" /> 
        <beans:property name="exceptionIfMaximumExceeded" value="false" />
        </beans:bean> 

        <beans:bean class="org.springframework.security.web.authentication.session.SessionFixationProtectionStrategy"> 
        </beans:bean>

        <beans:bean class="org.springframework.security.web.authentication.session.RegisterSessionAuthenticationStrategy">
        <beans:constructor-arg ref="sessionRegistry"/>
        </beans:beans>
    </beans:list>
</beans:constructor-arg>
</beans:beans>

    <beans:bean id="sessionRegistry" class="org.springframework.security.core.session.SessionRegistryImpl" />

    <beans:bean id="loginUrlAuthenticationEntryPoint" class="org.springframework.security.web.authentication.LoginUrlAuthenticationEntryPoint"> 
    <beans:constructor-arg name="loginFormUrl" value="/web/Default.html" />
    </beans:bean>
</beans:beans>

dispatcher-servlet.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:p="http://www.springframework.org/schema/p" 
xmlns:context="http://www.springframework.org/schema/context" 
xmlns:mvc="http://www.springframework.org/schema/mvc" 
xmlns:aop="http://www.springframework.org/schema/aop" 
xmlns:jee="http://www.springframework.org/schema/jee" 
xmlns:lang="http://www.springframework.org/schema/lang" 
xmlns:tx="http://www.springframework.org/schema/tx" 
xmlns:util="http://www.springframework.org/schema/util" 
xmlns:beans="http://www.springframework.org/schema/beans" 
xmlns:security="http://www.springframework.org/schema/security" 
xmlns:task="http://www.springframework.org/schema/task" 
xmlns:cache="http://www.springframework.org/schema/cache" 
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd    
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd 
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop.xsd 
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd
http://www.springframework.org/schema/jee 
http://www.springframework.org/schema/jee/spring-jee.xsd 
http://www.springframework.org/schema/lang 
http://www.springframework.org/schema/lang/spring-lang.xsd
http://www.springframework.org/schema/tx 
http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/util 
http://www.springframework.org/schema/util/spring-util.xsd
http://www.springframework.org/schema/security 
http://www.springframework.org/schema/security/spring-security.xsd
http://www.springframework.org/schema/task 
http://www.springframework.org/schema/task/spring-task.xsd
http://www.springframework.org/schema/cache 
http://www.springframework.org/schema/cache/spring-cache.xsd">

<mvc: annotation-driven /> 

<context: annotation-config /> 
<context:component-scan base-package="com.est.asg" />
<context:component-scan base-package="com.est.utils" />

<cache:annotation-driven key-generator="enhancedDefaultKeyGenerator" />
<beans:bean id="enhanced DefaultKeyGenerator" class="com.est.cache.interceptor.EnhancedDefaultKeyGenerator" />
<beans:bean id="cacheManager" class="org.springframework.cache.ehcache.EhCacheCacheManager" p:cacheManager-ref="ehcache" />
<beans:bean id="ehcache" class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean" p:configLocation="classpath:ehcache.xml" p:shared="true" />

<beans:bean id="jspViewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver"> 
<property name="viewClass" value="org.springframework.web.servlet.view.JstlView" /> 
<property name="prefix" value="WEB-INF/pages/" />
<property name="suffix" value=".jsp" /> 
</beans:bean>

<resources mapping="/resources/***location="/resources/" />

<!-- DB --> 
<beans:bean id="estjdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate"> 
<property name="dataSource" ref="dataSource" />
</beans:bean>

<beans:bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean"> 
<property name="jndiName">
<value>jdbc/ds</value>
</property>
</beans:bean>

<beans:bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager" scope="singleton"> 
<property name="dataSource" ref="dataSource" />
</beans:bean>

<tx:annotation-driven transaction-manager="transactionManager" />

<beans:bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver"> 
<property name="maxUploadSize" value="100000000" />
</beans:bean>

<task:executor id="Executor" pool-size="1" /> 
<task:scheduler id="Scheduler" pool-size="1" /> 
<task:annotation-driven executor="Executor" scheduler="Scheduler" />
</beans>

追踪

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497) 
at org.springframework.beans.factory.support.SimpleInstantiationStrategy: instantiate(SimpleInstantiationStrategy.java:154)
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:579)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.InstantiateUsingFactoryMethod (AbstractAutowireCapableBeanFactory.java:1250)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1099)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:545) 
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:502)
at org.springframework.beans.factory.support.AbstractBeanFactory.lambdasdoGetBean$0(AbstractBeanFactory.java:312) 
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:310) 
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200)
at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:251)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1138) 
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultlistableBeanFactory.java:1065)

at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:584)
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:91) 
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:373)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1344) 
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:582)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:502)
at org.springframework.beans.factory.support.AbstractBeanFactory.Lambda$doGetBean$0(AbstractBeanFactory.java:312)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:310)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:760)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:868)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:549)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:409) 
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:291)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:103)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4716)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5177)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1384) 
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1374)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)

at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75) 
at java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:134)
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:909) 
at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:843)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) 
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1384)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1374)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75) 
at java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:134)
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:909)
at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:262) 
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.core.StandardService.startInternal(StandardService.java:434)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) 
at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:930)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.startup.Catalina.start(Catalina.java:772) 
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497) 
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:342)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:473)

org.apache.catalina.startup.HostConfig deployDirectory 
INFO: Deploying web application directory [C:\Program Files\apache-tomcat-9.0.46\webapps\docs]
org.apache.jasper.servlet.TldScanner scanJars
INFO: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARS that were scanned but no TLDs were found in them. Skipping unneeded JARS during scanning can improve startup time and JSP compilation time.
org.apache.catalina.core.ApplicationContext log 
INFO: No Spring WebApplicationInitializer types detected on classpath
org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deployment of web application directory [C:\Program Files\apache-tomcat-9.0.46\webapps\docs]has finished in [3,125] ms 
org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory [C:\Program Files\apache-tomcat-9.0.46\webapps\examples] 
org.apache.jasper.servlet.TldScanner scanJars
INFO: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARS that were scanned but no TLDs were found in them. Skipping unneeded JARS during scanning can improve startup time and JSP compilation time.
org.apache.catalina.core.ApplicationContext log 
INFO: No Spring WebApplication Initializer types detected on classpath
org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: context Initialized()

org.apache.catalina.core.ApplicationContext log 
INFO: SessionListener: contextInitialized()
org.apache.catalina.core.ApplicationContext log 
INFO: ContextListener: attributeAdded("StockTicker', 'async.Stockticker@429c86bf')
org.apache.catalina.startup.HostConfig deployDirectory 
INFO: Deployment of web application directory [C:\Program Files\apache-tomcat-9.0.46\webapps\examples] has finished in [3,178] ms
org.apache.catalina.startup.HostConfig deployDirectory 
INFO: Deploying web application directory [C:\Program Files\apache-tomcat-9.0.46)webapps\host-manager] 
org.apache.jasper.servlet.TldScanner scanJars
INFO: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of 3ARs that were scanned but no TLDs were found in them. Skipping unneeded JARS during scanning can improve startup time and 3SP compilation time.
org.apache.catalina.core.ApplicationContext log 
INFO: No Spring WebApplicationInitializer types detected on classpath
org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deployment of web application directory [C:\Program Files\apache-tomcat-9.0.46\webapps host-manager] has finished in [2,588] ms 
org.apache.catalina.startup.HostConfig deployDirectory 
INFO: Deploying web application directory [C:\Program Files\apache-tomcat-9.0.46\webapps\manager]
org.apache.Jasper.servlet.TldScanner scanJars 
INFO: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARS during scanning can improve startup time and JSP compilation time.
org.apache.catalina.core.ApplicationContext log
INFO: No Spring WebApplicationInitializer types detected on classpath 
org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deployment of web application directory [C:\Program Files\apache-tomcat-9.0.46\webapps\manager] has finished in [2,481] ms
org.apache.catalina.startup.HostConfig deployDirectory 
INFO: Deploying web application directory [C:\Program Files\apache-tomcat-9.0.46\webapps\ROOT]
org.apache. jasper.servlet.TldScanner scanJars 
INFO: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARS that were scanned but no TLDs were found in them. Skipping unneeded JARS during scanning can improve startup time and JSP compilation time. 
org.apache.catalina.core.ApplicationContext log
INFO: No Spring WebApplication Initializer types detected on classpath 
org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deployment of web application directory [C:\Program Files\apache-tomcat-9.0.46\webapps\ROOT] has finished in [2,308] ms
org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-nio-9090"]
org.apache.catalina.startup.Catalina start
INFO: Server startup in [87859] milliseconds

文件夹结构

+EST
 +Java Resources
 +src/main/java
 +src/main/resources
 +config
 +est
 +Libraries
 +JavaScript Resources
 +Referenced Libraries
 +Deployed Resources
 +src
  +main
   +java
   +resources
   +webapp
    +META-INF
    +pages
    +resources
    +WEB-INF
     +lib
     -dispatcher-servlet.xml
     -spring-security.xml
     -web.xml
pom.xml

我正在将我的应用程序从SpringMVC版本3.x升级到5.x,并将tomcat版本9.x。我已经根据SpringMVC5更新了spring-security.xml,在更改设置后,我收到了页面未找到消息。当我试图点击任何静态页面或服务器页面时,它正在重定向到/web/default.html页面。我已经检查了上下文路径和spring-security.xml文件。请说明为什么页面总是重定向到/web/default.html

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题