配置文件如下<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:s="http://www.springframework.org/schema/security"
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-2.5.xsd
http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-2.0.4.xsd"
default-autowire="byType" default-lazy-init="true"> <description>使用SpringSecurity的安全配置文件</description> <!-- http安全配置 -->
<s:http auto-config="true" access-decision-manager-ref="accessDecisionManager">
<s:form-login login-page="/login.jsp" default-target-url="/index.jsp"
authentication-failure-url="/login.jsp?error=1" />
<s:logout invalidate-session="true" logout-success-url="/" />
<s:remember-me key="e37f4b31-0c45-11dd-bd0b-0800200c9a66" />
<!-- <s:intercept-url pattern="/**" requires-channel="https"/> -->
</s:http> <!-- 认证配置 -->
<s:authentication-provider user-service-ref="userDetailsService">
<!--可设置hash使用sha1或md5散列密码后再存入数据库 -->
<s:password-encoder hash="sha" />
</s:authentication-provider> <!-- 项目实现的用户查询服务 -->
<bean id="userDetailsService" class="com.sonata.dashboard.service.security.UserDetailsServiceImpl" /> <!-- 授权判断配置, 将授权名称的默认前缀由ROLE_改为A_. -->
<bean id="accessDecisionManager" class="org.springframework.security.vote.AffirmativeBased">
<property name="decisionVoters">
<list>
<bean class="org.springframework.security.vote.RoleVoter">
<property name="rolePrefix" value="A_" />
</bean>
<bean class="org.springframework.security.vote.AuthenticatedVoter" />
</list>
</property>
</bean>
</beans>页面如下:
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
<title>User Login</title>
<script type="text/javascript">
<c:if test="${param.error == '1'}">
document.onLoad = function(){
$.messager.alert('登录失败','用户名或者密码不正确!','error');
};
</c:if>
</script>
</head>
<body>
<center>
<form action="${pageContext.request.contextPath}/j_spring_security_check">
<table border="0">
<tr>
<td>USERNAME</td>
<td><input type="text" name="j_username" id="j_username"/></td>
</tr>
<tr>
<td>PASSWORD</td>
<td><input type="password" name="j_password" id="j_password"/></td>
</tr>
<tr>
<td align="center"><input type="submit" value="Submit"/></td>
<td align="center"><input type="reset"/></td>
</tr>
</table>
</form>
</center>
</body>
</html>
The webpage cannot be found
HTTP 404
Most likely causes:
•There might be a typing error in the address.
•If you clicked on a link, it may be out of date.
What you can try:
Retype the address.
Go back to the previous page.
Go to and look for the information you want.
这样的错误 哪里出了问题
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:s="http://www.springframework.org/schema/security"
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-2.5.xsd
http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-2.0.4.xsd"
default-autowire="byType" default-lazy-init="true"> <description>使用SpringSecurity的安全配置文件</description> <!-- http安全配置 -->
<s:http auto-config="true" access-decision-manager-ref="accessDecisionManager">
<s:form-login login-page="/login.jsp" default-target-url="/index.jsp"
authentication-failure-url="/login.jsp?error=1" />
<s:logout invalidate-session="true" logout-success-url="/" />
<s:remember-me key="e37f4b31-0c45-11dd-bd0b-0800200c9a66" />
<!-- <s:intercept-url pattern="/**" requires-channel="https"/> -->
</s:http> <!-- 认证配置 -->
<s:authentication-provider user-service-ref="userDetailsService">
<!--可设置hash使用sha1或md5散列密码后再存入数据库 -->
<s:password-encoder hash="sha" />
</s:authentication-provider> <!-- 项目实现的用户查询服务 -->
<bean id="userDetailsService" class="com.sonata.dashboard.service.security.UserDetailsServiceImpl" /> <!-- 授权判断配置, 将授权名称的默认前缀由ROLE_改为A_. -->
<bean id="accessDecisionManager" class="org.springframework.security.vote.AffirmativeBased">
<property name="decisionVoters">
<list>
<bean class="org.springframework.security.vote.RoleVoter">
<property name="rolePrefix" value="A_" />
</bean>
<bean class="org.springframework.security.vote.AuthenticatedVoter" />
</list>
</property>
</bean>
</beans>页面如下:
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
<title>User Login</title>
<script type="text/javascript">
<c:if test="${param.error == '1'}">
document.onLoad = function(){
$.messager.alert('登录失败','用户名或者密码不正确!','error');
};
</c:if>
</script>
</head>
<body>
<center>
<form action="${pageContext.request.contextPath}/j_spring_security_check">
<table border="0">
<tr>
<td>USERNAME</td>
<td><input type="text" name="j_username" id="j_username"/></td>
</tr>
<tr>
<td>PASSWORD</td>
<td><input type="password" name="j_password" id="j_password"/></td>
</tr>
<tr>
<td align="center"><input type="submit" value="Submit"/></td>
<td align="center"><input type="reset"/></td>
</tr>
</table>
</form>
</center>
</body>
</html>
The webpage cannot be found
HTTP 404
Most likely causes:
•There might be a typing error in the address.
•If you clicked on a link, it may be out of date.
What you can try:
Retype the address.
Go back to the previous page.
Go to and look for the information you want.
这样的错误 哪里出了问题
解决方案 »
- 求助啊!struts和网页框架集的问题
- 各位高手进来帮帮我...急。。。。在线等
- Spring的Template-Callback的简单实现
- <c:out>标签输出值时 能设置输出字体的颜色吗
- resin3.1.3配置连接池,通过hibernate访问数据库失败,而resin3.0.19成功,怎么解决?
- 如何用超链接调用SERVLET
- 这句HQL是什么意识
- 请问,hibernate能操作视图吗?假如能的话,请给些参考代码或者站点信息!
- Weblogic下包引用路径的问题
- 不能从sun的网站下载j2ee sdk.哪位网友能给个连接下载
- spring mvc aop的Aspect配置为什么不起作用
- Web+Spring 用什么 server比较好?
这一段没配置全
再加上一个参数 login-processing-url="/j_spring_security_check"