java7找不到uri_java – 在DispatcherServlet中找不到带有URI j_spring_security_check的HTTP请求的映射...

这是我的春季安全Bean

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-3.1.xsd

http://www.springframework.org/schema/security

http://www.springframework.org/schema/security/spring-security-3.1.xsd">

authentication-failure-url="/loginfailed" />

这是我的MVC-dispatcher servlet

xmlns:context="http://www.springframework.org/schema/context"

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mvc="http://www.springframework.org/schema/mvc"

xmlns:tx="http://www.springframework.org/schema/tx"

xsi:schemaLocation="

http://www.springframework.org/schema/beans

http://www.springframework.org/schema/beans/spring-beans-3.1.xsd

http://www.springframework.org/schema/tx

http://www.springframework.org/schema/tx/spring-tx-3.1.xsd

http://www.springframework.org/schema/context

http://www.springframework.org/schema/context/spring-context-3.1.xsd

http://www.springframework.org/schema/mvc

http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd">

class="org.springframework.orm.jpa.support.SharedEntityManagerBean">

class="org.springframework.orm.jpa.LocalEntityManagerFactoryBean">

class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor" />

class="org.springframework.web.servlet.view.UrlBasedViewResolver">

org.springframework.web.servlet.view.tiles2.TilesView

class="org.springframework.web.servlet.view.tiles2.TilesConfigurer">

/WEB-INF/tiles.xml

这是我的web.xml

xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"

xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://www.oracle.com/webfolder/technetwork/jsc/xml/ns/javaee/web-app_3_0.xsd"

id="WebApp_ID" version="3.0">

Spring MVC Application

mvc-dispatcher

org.springframework.web.servlet.DispatcherServlet

1

mvc-dispatcher

/

org.springframework.web.context.ContextLoaderListener

contextConfigLocation

/WEB-INF/mvc-dispatcher-servlet.xml,

/WEB-INF/spring-security.xml

springSecurityFilterChain

org.springframework.web.filter.DelegatingFilterProxy

springSecurityFilterChain

/*

这是我的控制器

@Controller

@RequestMapping(value = "/c")

public class MainController {

@RequestMapping(value = "/welcome", method = RequestMethod.GET)

public String printWelcome(ModelMap model, Principal principal) {

String name = principal.getName();

model.addAttribute("username", name);

model.addAttribute("message", "Spring Security Custom Form example");

return "hello";

}

@RequestMapping(value = "/login", method = RequestMethod.GET)

public String login(ModelMap model) {

return "login";

}

@RequestMapping(value = "/loginfailed", method = RequestMethod.GET)

public String loginerror(ModelMap model) {

model.addAttribute("error", "true");

return "login";

}

@RequestMapping(value = "/logout", method = RequestMethod.GET)

public String logout(ModelMap model) {

return "login";

}

}

我的问题是当我访问localhost:8080 / apsas / c / welcome我得到了

HTTP ERROR 500

Server Error

java.lang.NullPointerException

at com.apsas.controller.MainController.printWelcome(MainController.java:30)

我可以成功进入登录页面,但点击提交按钮后,我得到http错误404问题访问/ apsas / c / j_spring_security_check.

这是日志

警告:在DispatcherServlet中找不到带有URI [/ apsas / c / j_spring_security_check]的HTTP请求的映射,名称为“mvc-dispatcher”

我可以成功访问我的瓷砖中定义的一些页面,除了应该指示我登录的欢迎.请帮忙

最佳答案 默认的spring security登录页面是[application context] / j_spring_security_check

您的登录页面正在提交到/ apsas / c / j_spring_security_check.假设您的应用程序上下文是apsas,您的登录表单应该提交到/ apsas / j_spring_security_check或../j_spring_security_check.

要清楚,这是登录页面上表单元素的action属性的值.如果您需要帮助,请将登录页面发布到问题中,我可以更具体.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值