web.xml中的Dispatcher servlet条目不允许登录视图(AngularJS)加载(404)

时间:2016-11-09 13:03:35

标签: angularjs spring rest login spring-security

在我删除调度程序servlet配置时在AngularJS中执行SPA 在web.xml中会出现登录视图页面,但是如果我放置了调度程序 web.xml登录页面中的servlet条目不会加载(显示)并显示HTTP 404。

我无法解决此问题,是否应该添加任何额外配置? 使用的技术是Spring REST而不是MVC,Spring Security和AngularJS。

可以请有人给出解决方案吗?

以下是文件。

web.xml

<web-app>
    <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>  

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

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

    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>/WEB-INF/test-servlet.xml</param-value>
    </context-param>

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

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

test-servlet(调度程序servlet) .xml

<beans>
    <context:annotation-config/>
    <mvc:annotation-driven />

    <context:component-scan base-package="com.org.simpro"/>

    <jpa:repositories base-package="com.org.simpro"></jpa:repositories> 

    <bean id="hibernateJpaVendorAdapter" class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
    </bean>

    <bean id="HelloWorldRestController" class="com.org.simpro.controller.HelloWorldRestController">
        <property name="userService" ref="userServiceImpl"></property>
    </bean> 

    <bean id= "userServiceImpl" class="com.org.simpro.service.UserServiceImpl">
    </bean>

    <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
        <property name="driverClassName" value="oracle.jdbc.OracleDriver"/>
        <property name="url" value="jdbc:oracle:thin:@localhost:1521:xe"/>
        <property name="username" value="HR"/>
        <property name="password" value="hr"/>
    </bean>

    <bean id="entityManagerFactory"  class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
        <property name="dataSource" ref="dataSource"></property>
        <property name="jpaVendorAdapter" ref="hibernateJpaVendorAdapter"></property>
        <property name="packagesToScan" value="com.org.simpro.model" />
        <property name="jpaProperties">

            <props>
                <prop key="hibernate.dialect">org.hibernate.dialect.Oracle9Dialect</prop>
                            <!-- 
                                <prop key="javax.persistence.schema-generation.database.action">none</prop>
                                <prop key="hibernate.ejb.use_class_enhancer">true</prop>

                                //jpa hibernate properties
                                hibernate.dialect=org.hibernate.dialect.H2Dialect
                                hibernate.format_sql=true
                                hibernate.hbm2ddl.auto=create-drop
                                hibernate.ejb.naming_strategy=org.hibernate.cfg.ImprovedNamingStrategy
                                hibernate.show_sql=false
                            -->
                <prop key="hibernate.format_sql">true</prop>
                <prop key="hibernate.hbm2ddl.auto">create-drop</prop>
                <prop key="hibernate.ejb.naming_strategy">org.hibernate.cfg.ImprovedNamingStrategy</prop>
                <prop key="hibernate.show_sql">true</prop>   
            </props>
        </property> 
    </bean>

    <bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
            <property name="entityManagerFactory" ref="entityManagerFactory"/>
    </bean>

    <tx:annotation-driven transaction-manager="transactionManager"/>
    <import resource="security-context.xml"/> 
</beans>

0 个答案:

没有答案