mardi 2 août 2016

what's changed spring-mvc between 4.1.x and 4.3.x

I have created a spring-mvc project using Maven today, when i use the version 4.1.5, the spring-mvc container inject the param to the handler(the method in the class which have a @Controller upon it) correctly, but when i use the version of 4.3.0,the spring-mvc container don't inject any params to the handler, such as HttpServeltRequest,Model,@RequestParam ,and so on. I used the same config file between tow versions,I only changed the version in the pom.xml . Can someone help me,thank you very much!

the web.xml's content is below:

<web-app>
  <display-name>Archetype Created Web Application</display-name>
  <servlet>
  <servlet-name>spring</servlet-name>
  <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <init-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>classpath:conf/spring-servlet.xml</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
  </servlet>
  <servlet-mapping>
    <servlet-name>spring</servlet-name>
    <url-pattern>/</url-pattern>
  </servlet-mapping>

  <welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
  </welcome-file-list>
</web-app>

and the spring-servlet.xml's content below:

<context:component-scan base-package="com.tydic.rmp.controller">
</context:component-scan>

at last, the controller's content below:

package com.tydic.rmp.controller;
import javax.servlet.http.HttpServletRequest;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
public class LoginController {
    @RequestMapping(value={"/login"})
    public String login(Model model, HttpServletRequest request) {
        model.addAttribute("hello", "111");
        System.out.println(request);
        return "login.jsp";
    }

    public LoginController() {
        System.out.println("========111111111111");
    }

}




Aucun commentaire:

Enregistrer un commentaire