2016-08-27 16 views
1

ModelMapやModelのような他のものを追加する場合、私のコントローラメソッドでRedirectAttributesを使用しているときは、何のエラーも与えない。どうして?java.lang.IllegalArgumentExceptionが発生しました:Spring MVCで "RedirectAttributes"を使用した場合の引数タイプの不一致エラー

解決策のネットを確認しましたが、何も見つかりませんでした。

java.lang.IllegalArgumentExceptionが:引数の型の不一致 sun.reflect.NativeMethodAccessorImpl.invoke0(ネイティブメソッド)春バージョンは何

春-servlet.xml

   <beans xmlns="http://www.springframework.org/schema/beans" 
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
       xmlns:p="http://www.springframework.org/schema/p" 
       xmlns:context="http://www.springframework.org/schema/context" 
       xmlns:tx="http://www.springframework.org/schema/tx" 
       xmlns:mvc="http://www.springframework.org/schema/mvc" 
       xsi:schemaLocation="http://www.springframework.org/schema/beans 
        http://www.springframework.org/schema/beans/spring-beans-3.0.xsd 
        http://www.springframework.org/schema/context 
        http://www.springframework.org/schema/context/spring-context-3.0.xsd 
        http://www.springframework.org/schema/mvc 
        http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd 
        http://www.springframework.org/schema/tx 
        http://www.springframework.org/schema/tx/spring-tx.xsd"> 


       <context:component-scan base-package="com.controller" /> 
       <mvc:annotation-driven /> 
       <bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource"> 
        <property name="basename" value="classpath:messages" /> 
        <property name="defaultEncoding" value="UTF-8" /> 
       </bean> 

       <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"> 
        <property name="driverClassName" value="oracle.jdbc.driver.OracleDriver" /> 
        <property name="url" value="jdbc:oracle:thin:@localhost:1521:xe" /> 
        <property name="username" value="system" /> 
        <property name="password" value="system" /> 
      </bean> 
      <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> 
       <property name="dataSource" ref="dataSource" /> 
       <property name="configLocation"> 
       <value>classpath:hibernate.cfg.xml</value> 
       </property> 
       <property name="configurationClass"> 
       <value>org.hibernate.cfg.AnnotationConfiguration</value> 
       </property> 
       <property name="hibernateProperties"> 
       <props> 
        <prop key="hibernate.dialect">org.hibernate.dialect.Oracle9Dialect</prop> 
        <prop key="hibernate.show_sql">true</prop> 
       </props> 
       </property> 
      </bean> 
      <bean id="userDAO" class="userDAO.UserDAOImpl"/> 
      <bean id="userService" class="userService.UserServiceImpl"/> 
       <bean id="viewResolver" 
        class="org.springframework.web.servlet.view.UrlBasedViewResolver"> 
        <property name="viewClass"> 
         <value> 
          org.springframework.web.servlet.view.tiles2.TilesView 
         </value> 
        </property> 
       </bean> 
       <bean id="tilesConfigurer" 
        class="org.springframework.web.servlet.view.tiles2.TilesConfigurer"> 
        <property name="definitions"> 
         <list> 
          <value>/WEB-INF/tiles.xml</value> 
         </list> 
        </property> 
       </bean> 


       <tx:annotation-driven transaction-manager="transactionManager"/> 
       <bean id="transactionManager" 
        class="org.springframework.orm.hibernate3.HibernateTransactionManager"> 
       <property name="sessionFactory" ref="sessionFactory"></property> 
      </bean> 

      </beans> 

     //Controller class 
       @RequestMapping("/Check") 
      public String Check(@ModelAttribute("adduser") User user,ModelMap model,RedirectAttributes rd) 
    //This is my function 
      { 
       System.out.println(user.getUsername()); 
       System.out.println(user.getPassword()); 
       rd.addFlashAttribute("ajay", "Cjal"); 
       model.addAttribute("Username",user.getUsername()); 
       User result=userService.getByUserName(user.getUsername()); 
       System.out.println(result); 
       if(result == null) 
       { 
        userService.addUser(user); 
        return "redirect:SuccessfulRegistration.html"; 
       } 
       else 
       { 
        return "redirect:RegistrationError.html"; 
       } 

      } 

答えて

関連する問題