として、私は多くの人が私と同じ問題があったが、それでも他の提案で、私はまだ持っていることを見ましたこの問題は未解決です。 Spring MVCの、java.lang.IllegalStateException:どちらBindingResultやBean名用プレーンなターゲット・オブジェクトのユーザーフォーム "利用可能要求属性
この
は、これは私のMCV-ディスパッチャ-servlet.xml<beans xmlns="http://www.springframework.org/schema/beans"
\t xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
\t xmlns:context="http://www.springframework.org/schema/context"
\t xmlns:mvc="http://www.springframework.org/schema/mvc"
\t xsi:schemaLocation="http://www.springframework.org/schema/beans
\t \t \t \t \t \t http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
\t \t \t \t \t \t http://www.springframework.org/schema/mvc
\t \t \t \t http://www.springframework.org/schema/mvc/spring-mvc.xsd
\t \t \t \t \t \t http://www.springframework.org/schema/context
\t \t \t \t http://www.springframework.org/schema/context/spring-context.xsd"
\t >
\t
\t <mvc:annotation-driven/>
\t <context:component-scan base-package="danco.finances.webinterface.spring.config" />
</beans>
これは私のjspである私のweb.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
\t xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
\t xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
\t id="WebApp_ID" version="2.5">
\t <display-name>FINANCES</display-name>
\t <servlet>
\t \t <servlet-name>mvc-dispatcher</servlet-name>
\t <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
\t \t <load-on-startup>1</load-on-startup>
\t </servlet>
\t
\t <servlet-mapping>
\t \t <servlet-name>mvc-dispatcher</servlet-name>
\t <url-pattern>*.htm</url-pattern>
\t </servlet-mapping>
\t
\t <context-param>
\t \t <param-name>contextConfigLocation</param-name>
\t \t <param-value>/WEB-INF/mvc-dispatcher-servlet.xml</param-value>
\t </context-param>
\t <listener>
\t \t <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
\t </listener>
\t
\t <welcome-file-list>
\t \t <welcome-file>index.jsp</welcome-file>
\t </welcome-file-list>
</web-app>
ですファイル
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
<link rel="stylesheet" type="text/css" href="<%=request.getContextPath() %>/css/finances.css"/>
<script src="<%=request.getContextPath() %>/js/faio/fontawesome-io.js"></script>
</head>
<body>
\t
\t <div class="externalDiv">
\t \t <div class="internalDiv">
\t \t \t <div class="divUpperInfo">
\t \t \t \t <i class="fa fa-chevron-circle-right"></i> LOGIN
\t \t \t </div>
\t \t \t <div class="divUnderInfo">
\t \t \t \t <div class="div-form" align="center">
\t \t \t \t \t <form:form method="post" modelAttribute="userForm" action="login/login.htm">
\t \t \t \t \t \t <div class="div-top-end-space"> </div>
\t \t \t \t \t \t <div>
\t \t \t \t \t \t \t <form:label path="username" cssClass="form-label"><i class="fa fa-chevron-right fa-1"></i> USERNAME:</form:label>
\t \t \t \t \t \t \t <form:input path="username" type="text" />
\t \t \t \t \t \t </div>
\t \t \t \t \t \t <div class="div-separator"></div>
\t \t \t \t \t \t <div>
\t \t \t \t \t \t \t <input class="form-button" type="submit" value="LOGIN" />
\t \t \t \t \t \t </div>
\t \t \t \t \t \t <div class="div-top-end-space"> </div>
\t \t \t \t \t </form:form>
\t \t \t \t </div>
\t \t \t </div>
\t \t </div>
\t </div>
</body>
</html>
、すべての変更は、私がしようとしているため、これは、私は理解していない何私のコントローラ
package danco.finances.webinterface.auth.controller;
import org.springframework.stereotype.Controller;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;
import danco.finances.webinterface.auth.model.LoginResult;
import danco.finances.webinterface.auth.model.UserForm;
@Controller
@RequestMapping("/login")
public class LoginController {
\t @RequestMapping(value="/login.htm", method = RequestMethod.GET)
\t public ModelAndView loginGet(@ModelAttribute("userForm") UserForm userForm, BindingResult result) {
\t \t ModelAndView mv = new LoginResult("login");
\t \t mv.addObject("userForm", userForm);
\t \t mv.addObject("msg", userForm.getUsername());
\t \t return mv;
\t }
\t
\t @RequestMapping(value="/login.htm", method = RequestMethod.POST)
\t public ModelAndView loginPost(@ModelAttribute("userForm") UserForm userForm, BindingResult result) {
\t \t ModelAndView mv = new LoginResult("login");
\t \t mv.addObject("userForm", userForm);
\t \t mv.addObject("msg", userForm.getUsername());
\t \t return mv;
\t }
}
は、春はmodelAttributeをバインドする方法です私はJSPをロードしている間、いつもそのメッセージを受け取ります。 yを押してログインします)。
ありがとうございます。
このエントリを削除してください(これは「回答」ですので)、自分のエントリの下に「コメント」として追加してください。 –