Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 春季未提交表单(SimpleControl)_Java_Spring_Spring Mvc - Fatal编程技术网

Java 春季未提交表单(SimpleControl)

Java 春季未提交表单(SimpleControl),java,spring,spring-mvc,Java,Spring,Spring Mvc,我在我的控制器中扩展SimpleFormController,并使用formBackingObject方法在表单加载上显示一些数据。但当我在我的we页面上点击submit按钮时,表单未提交,事件未转到 我不知道出了什么问题,请帮助我 多谢各位 下面是我的代码 映射 <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns

我在我的控制器中扩展SimpleFormController,并使用formBackingObject方法在表单加载上显示一些数据。但当我在我的we页面上点击submit按钮时,表单未提交,事件未转到 我不知道出了什么问题,请帮助我

多谢各位

下面是我的代码

映射

<?xml  version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:aop="http://www.springframework.org/schema/aop"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:jee="http://www.springframework.org/schema/jee"
    xmlns:lang="http://www.springframework.org/schema/lang"
    xmlns:p="http://www.springframework.org/schema/p"
    xmlns:tx="http://www.springframework.org/schema/tx"
    xmlns:util="http://www.springframework.org/schema/util"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
        http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee.xsd
        http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang.xsd
        http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
        http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd">

<context:component-scan base-package="river.amit.com"/> 
    <bean id="viewResolver"     class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <property name="prefix">
            <value>/WEB-INF/jsp/</value>
        </property>
        <property name="suffix">
            <value>.jsp</value>
        </property>
    </bean>
    <bean class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
       <property name="mappings">
        <props>
           <prop key="/hello.html">helloController</prop>
           <prop key="/login.html">loginController</prop>
           <prop key="/role.html">roleController</prop>
           <prop key="/person.html">personController</prop>
          </props>
       </property>
    </bean>
    <bean id="helloController" class="river.amit.com.HelloWorldController"/>
    <bean id="loginController" class="river.amit.com.LoginController"/>
    <bean id="roleController" class="river.amit.com.RoleController"/>
    <bean id="personController" class="river.amit.com.PersonController">
    <property name="formView" value="person" />
    <property name="successView" value="message" />
    </bean>
        <bean id="localeChangeInterceptor"      class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor">
        <property name="paramName" value="hl" />
    </bean>
    <bean id="localeResolver"       class="org.springframework.web.servlet.i18n.SessionLocaleResolver" />
        <!-- Hibernate configuration -->
      <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">  
        <property name="driverClassName"  value="com.mysql.jdbc.Driver"></property>  
        <property name="url" value="jdbc:mysql://localhost:3306/river"></property>  
        <property name="username" value="root"></property>  
        <property name="password" value=""></property>  
    </bean>  
        <bean id="sessionFactory"
        class="org.springframework.orm.hibernate4.LocalSessionFactoryBean"> 
        <property name="dataSource" ref="dataSource"></property>  
        <property name="mappingResources">  
        <list>  
        <value>\river\amit\com\curd\login.hbm.xml</value>  
         <value>\river\amit\com\curd\Person.hbm.xml</value> 
        <value>\river\amit\com\curd\Role.hbm.xml</value>
         </list>  
        </property>  
          <property name="hibernateProperties">
            <value>
                hibernate.dialect=org.hibernate.dialect.MySQLDialect
                hibernate.show_sql=true
                hibernate.hbm2ddl.auto=update
            </value>
        </property>
    </bean>  
           <tx:annotation-driven/>
      <bean id="transactionManager"
        class="org.springframework.orm.hibernate4.HibernateTransactionManager">
        <property name="sessionFactory" ref="sessionFactory" />
    </bean> 

       <bean id="service" class="river.amit.com.service.LoginService"></bean>
       <bean id="logindao" class="river.amit.com.dao.LoginDao"> 
         <property name="sessionFactory" ref="sessionFactory"></property>  
    </bean> 
    <bean id="roleService" class="river.amit.com.service.RoleService"></bean>
      <bean id="roleDao" class="river.amit.com.dao.RoleDao">    
             <property name="sessionFactory" ref="sessionFactory"></property>  
    </bean>
     <bean id="personService" class="river.amit.com.service.PersonService"></bean>
      <bean id="personDao" class="river.amit.com.dao.PersonDao">    
             <property name="sessionFactory" ref="sessionFactory"></property>  
    </bean>
</beans>
jsp


登录页面





从spring配置文件中删除以下行

<context:component-scan base-package="river.amit.com"/>

或从扫描中排除
控制器

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Login Page</title>
</head>
<body>
<form:form  commandName="personForm" method="post">
<input type="text" name="firstName">  <br> <br> 
<form:input path="firstName"/> 
  <input type="text" name="contact"> <br><br> 
 <!--  <input type="text" name="email"><br> <br>
  <input type="text" name="address"><br><br> 
  <input type="text" name="login"><br><br> --> 
  <form:button name="submit" value="submit"></form:button>
  <input type="submit" value="Submit" />  
</form:form>
  <a href="role.html">Role</a>
</body>
</html>
<context:component-scan base-package="river.amit.com"/>