为啥找不到j_spring_security_check咧?居然报404~-问答-阿里云开发者社区-阿里云

开发者社区> 问答> 正文
阿里云
为了无法计算的价值
打开APP
阿里云APP内打开

为啥找不到j_spring_security_check咧?居然报404~

2016-03-17 14:42:04 4709 1
不知道xml哪里配得不对,在表单action的j_spring_security_check,老是跳转不过去,找不到j_spring_security_check,报404.

<%=request.getContextPath() %>/j_spring_security_check之类的方式都试过了,没用。

依然报404

<?xml version="1.0" encoding="UTF-8"?>
<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"
    xmlns:jdbc="http://www.springframework.org/schema/jdbc"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
                        http://www.springframework.org/schema/jdbc  http://www.springframework.org/schema/jdbc/spring-jdbc-3.0.xsd
                        http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.1.xsd">
        <http pattern="/common/**" security="none" />
    <http pattern="/css/**" security="none" />
    <http pattern="/images/**" security="none" />
    <http pattern="/js/**" security="none" />
    <http pattern="/login**" security="none"/>
    <http pattern="/manager_login.action" security="none"/>
     
    <http auto-config="true" use-expressions="true">
        <!-- 访问无权限时处理 -->
        <access-denied-handler ref="accessDeniedHandler" />
 
        <!-- 允许所有身份访问的路径 -->
         <intercept-url pattern="/**" access="permitAll"/> 
 
        <!-- 无受权路径任何人都不能访问 -->
        <intercept-url pattern="/securityExample/nobody" access="denyAll" />
         
        <!-- 定义模块可访问所需的资源 -->
        <intercept-url pattern="/admin/add" access="hasRole('/admin/add')"/>
        <intercept-url pattern="/admin/update" access="hasRole('/admin/update')"/>
        <intercept-url pattern="/admin/modify" access="hasRole('/admin/modify')"/>
        <intercept-url pattern="/admin/delete" access="hasRole('/admin/delete')"/>
        <intercept-url pattern="/admin/handle" access="hasRole('/admin/handle')"/>
         
        <intercept-url pattern="/doctor/add" access="hasRole('/doctor/add')"/>
        <intercept-url pattern="/doctor/update" access="hasRole('/doctor/update')"/>
        <intercept-url pattern="/doctor/modify" access="hasRole('/doctor/modify')"/>
        <intercept-url pattern="/doctor/delete" access="hasRole('/doctor/delete')"/>
        <intercept-url pattern="/doctor/handle" access="hasRole('/doctor/handle')"/>
         
        <intercept-url pattern="/article/add" access="hasRole('/article/add')"/>
        <intercept-url pattern="/article/update" access="hasRole('/article/update')"/>
        <intercept-url pattern="/article/modify" access="hasRole('/article/modify')"/>
        <intercept-url pattern="/article/delete" access="hasRole('/article/delete')"/>
        <intercept-url pattern="/article/handle" access="hasRole('/article/handle')"/>
         
        <intercept-url pattern="/cs/add" access="hasRole('/cs/add')"/>
        <intercept-url pattern="/cs/update" access="hasRole('/cs/update')"/>
        <intercept-url pattern="/cs/modify" access="hasRole('/cs/modify')"/>
        <intercept-url pattern="/cs/delete" access="hasRole('/cs/delete')"/>
        <intercept-url pattern="/cs/handle" access="hasRole('/cs/handle')"/>
         
         
        <!-- 允许所有己验证用户访问所有文件夹 -->
        <!-- <intercept-url pattern="/**/*" access="authenticated" />
 
        登录退出页面控制
        <form-login login-page="/login" authentication-failure-url="/login?error=true"
            default-target-url="/index" always-use-default-target='true'
            login-processing-url="/login_url" />
        <logout invalidate-session="true" logout-success-url="/login"
            logout-url="/logout_url" /> -->
             
        <form-login login-page="/login.jsp"
                    login-processing-url="/medical/manager_login.action"
                    authentication-failure-url="/manager_login.action?error=1"/>
    </http>
 
    <!-- 验证管理器负责验证用户凭证 -->
    <authentication-manager >
        <!-- 用户密码用md5加密  -->
        <!-- <authentication-provider user-service-ref="jdbcUserService">
            <password-encoder hash="md5" />
        </authentication-provider> -->
        <authentication-provider>
            <password-encoder hash="plaintext"/>
            <user-service>
                <user name="admin3" authorities="ROLE_ADMIN" password="123456"/>
            </user-service>
        </authentication-provider>
    </authentication-manager>
     
     
</beans:beans>
<?xml version="1.0" encoding="UTF-8"?>
<!-- Application context definition for PetClinic Datasource. -->
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
    xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
    xmlns:p="http://www.springframework.org/schema/p" xmlns:jaxws="http://cxf.apache.org/jaxws"
    xmlns:cxf="http://cxf.apache.org/core"
    xsi:schemaLocation="http://www.springframework.org/schema/beans  
           http://www.springframework.org/schema/beans/spring-beans-2.5.xsd  
           http://www.springframework.org/schema/aop   
           http://www.springframework.org/schema/aop/spring-aop-2.5.xsd  
           http://www.springframework.org/schema/context  
           http://www.springframework.org/schema/context/spring-context-2.5.xsd    
           http://www.springframework.org/schema/tx   
           http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
           http://cxf.apache.org/jaxws     
           http://cxf.apache.org/schemas/jaxws.xsd     
           http://cxf.apache.org/core     
           http://cxf.apache.org/schemas/core.xsd
           ">
 
    <bean class="org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor" />
    <!-- 自动扫描com.toceansoft.模块.dao包下所有标注@Repository的DAO组件(自动注入) -->
    <context:component-scan base-package="com.toceansoft.medical.*.dao.impl" />
    <!-- 自动扫描com.hiting.service包下所有标注@Service的服务组件 -->
    <context:component-scan base-package="com.toceansoft.medical.*.service.impl" />
    <context:component-scan base-package="com.toceansoft.medical.webservice.*.cxf.service.impl" />
    <context:component-scan base-package="com.toceansoft.medical.webservice.login.cxf.tokonservice.impl" />
    <!-- 自动扫描@Controller标注的类控制器类 -->
    <context:component-scan base-package="com.toceansoft.medical.*.web" />
    <context:component-scan
        base-package="com.toceansoft.medical.webservice.*.cxf.action" />
 
 
    <!-- 加载配置文件 -->
    <!-- <context:property-placeholder location="classpath:/spring/resources.properties" /> -->
 
    <!-- c3p0配置 -->
    <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"
        destroy-method="close">
        <property name="driverClass" value="com.mysql.jdbc.Driver" />
        <property name="jdbcUrl" value="jdbc:mysql://127.0.0.1:3306/medical" />
        <property name="user" value="root" />
        <property name="password" value="740762239" />
 
        <!--连接池中保留的最大连接数。Default: 15 -->
        <property name="maxPoolSize" value="15" />
 
        <!--连接池中保留的最小连接数。 -->
        <property name="minPoolSize" value="20" />
 
        <!--初始化时获取的连接数,取值应在minPoolSize与maxPoolSize之间。Default: 3 -->
        <property name="initialPoolSize" value="2" />
 
        <!--最大空闲时间,60秒内未使用则连接被丢弃。若为0则永不丢弃。Default: 0 -->
        <property name="maxIdleTime" value="30" />
 
    </bean>
 
    <!-- spring jdbc -->
    <!-- <bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
        <property name="dataSource" ref="dataSource" />
    </bean> -->
 
    <!-- hibnerate4 -->
    <bean id="sessionFactory"
        class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
        <!--<qualifier value="sessionFactory"></qualifier>-->
        <property name="dataSource">
            <ref bean="dataSource" />
        </property>
        <property name="packagesToScan">
            <list>
                <value>com.toceansoft.medical.*.bean</value>
            </list>
        </property>
        <property name="hibernateProperties">
            <props>
                <prop key="hibernate.dialect">org.hibernate.dialect.MySQL5InnoDBDialect</prop>
                <prop key="hibernate.show_sql">true</prop>
                <prop key="hibernate.connection.release_mode">auto</prop>
                <!--<prop key="hbm2ddl.auto">update</prop> -->
            </props>
        </property>
    </bean>
    <bean id="template" class="org.springframework.orm.hibernate3.HibernateTemplate"
        p:sessionFactory-ref="sessionFactory" />
    <!-- 使用hibernate4 事务 -->
    <bean id="transactionManager"
        class="org.springframework.orm.hibernate3.HibernateTransactionManager">
        <property name="sessionFactory" ref="sessionFactory" />
    </bean>
    <bean id="base" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean" abstract="true">  
        <property name="transactionManager" ref="transactionManager">  
        </property>  
        <property name="transactionAttributes">  
         <props>  
             <prop key="*">PROPAGATION_REQUIRED</prop>  
        </props>  
     </property>  
</bean> 
    <!-- 切入点表达式 -->
    <tx:advice id="txAdvice" transaction-manager="transactionManager">
        <tx:attributes>
            <tx:method name="*" propagation="REQUIRED" />
        </tx:attributes>
    </tx:advice>
 
    <!-- 切面 -->
    <aop:config>
        <aop:pointcut id="interceptorPointCuts"
            expression="execution(* com.toceansoft.medical.testdemo.dao.*.*(..))" />
        <aop:advisor advice-ref="txAdvice" pointcut-ref="interceptorPointCuts" />
    </aop:config>
 
    <!-- 切面  Add by Kuby -->
    <aop:config>
        <aop:pointcut id="serviceMethod"
            expression="execution(* com.toceansoft.medical.*.service.impl.*ServiceImpl.*(..))" />
        <aop:advisor advice-ref="txAdvice" pointcut-ref="serviceMethod" />
    </aop:config>
     
    <tx:annotation-driven />
 
    <!-- 帐号处理类 -->
    <bean id="jdbcUserService"
        class="org.springframework.security.core.userdetails.jdbc.JdbcDaoImpl">
        <property name="dataSource" ref="dataSource" />
        <!-- 使用组授权策略 -->
        <property name="enableGroups" value="true" />
        <!-- 不使用用户授权策略 -->
        <property name="enableAuthorities" value="false" />
 
        <!-- 匹配用户名 -->
        <property name="usersByUsernameQuery">
            <value>
                SELECT `user_name` as 'username', `password`, `is_delete` = 0 as `is_valid`
                FROM `t_admin` WHERE `user_name` = ?
            </value>
        </property>
 
        <!-- 获取用户所在组被授予的权限 -->
        <property name="groupAuthoritiesByUsernameQuery">
            <value>
                select u.r_id as 'role_id', u.r_id as 'role_name',module.module_address as resource_value 
                from t_admin u join t_role_module rm on rm.r_id = u.r_id
                join t_module module on module.m_id = rm.m_id
                where u.user_name = ?
            </value>
        </property>
    </bean>
 
    <!-- 无权限错误提示 -->
    <bean id="accessDeniedHandler" class="com.toceansoft.medical.security.HippoAccessDeniedHandler">
        <property name="accessDenied" value="/accessDenied" />
    </bean>
</beans>
<%@ page language="java" contentType="text/html; charset=UTF-8" %>  
<%@taglib prefix="s" uri="/struts-tags"%>  
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>
<html>  
    <head>  
    </head>  
    <body>  
        <!-- 使用form标签生成表单元素 --> 
        <form action="j_spring_security_check" method='post'>
            User Name:
        <input name="j_username" value="admin3" size="20" maxlength="50" type="text"/>
        <br />
        Password:
        <input name="j_password" value="123456" size="20" maxlength="50" type="password"/>
        <br />
        <input type="submit" value="Login"/>
        </form>  
    </body>  
</html>
取消 提交回答
全部回答(1)
  • a123456678
    2019-07-17 19:05:21

    那个是默认的url,formauthenticationfilter里没记错的话,你的

    0 0
相关问答

1

回答

spring security有什么作用呢?

2022-08-16 22:27:17 370浏览量 回答数 1

1

回答

Spring Security 有什么优点?

2021-11-04 21:23:46 279浏览量 回答数 1

1

回答

Spring Security的优点是什么?

2021-10-24 20:23:16 623浏览量 回答数 1

0

回答

A security issue can make a DoS attack in the ASM.

2021-04-20 20:18:57 187浏览量 回答数 0

1

回答

配置 spring security时,启动tomcat就报错了 :报错

2020-06-20 11:51:15 759浏览量 回答数 1

1

回答

配置 spring security时,启动tomcat就报错了?报错

2020-06-08 21:00:26 435浏览量 回答数 1

1

回答

配置 spring security时,启动tomcat就报错了:配置报错 

2020-06-02 19:30:19 363浏览量 回答数 1

1

回答

spring-security 配置的问题

2020-04-22 17:18:40 665浏览量 回答数 1

1

回答

spring-security中ajax请求的问题

2016-03-04 16:51:35 2778浏览量 回答数 1

1

回答

配置Spring-Security报错,找不到元素 'b:beans' 的声明

2016-03-05 10:43:59 5202浏览量 回答数 1
+关注
文章
问答
问答排行榜
最热
最新
相关电子书
更多
Spring Cloud Alibaba - 重新定义 Java Cloud-Native
立即下载
Java Spring Boot开发实战系列课程【第15讲】:Spring Boot 2.0 API与Spring REST Docs实战
立即下载
Java Spring Boot开发实战系列课程【第7讲】:Spring Boot 2.0安全机制与MVC身份验证实战(Java面试题)
立即下载