Use SpringMVC: step when <mvc view-controller /> tag a pit

<mvc: view-controller> tag

If some of us just want to jump page request, what does not need to background processing logic, we can not write a blank in the Action method to jump, jump controller configuration view of one of the following directly in the can (without Action, Jump directly to the page)

Written in jsp page:

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>首页</title>
</head>
<body>
    <a href="/hello_world">Hello World</a> <br />
</body>
</html>

In the configuration file is written:

<mvc:view-controller path="/" view-name="index2" />

In the controller class writes:

 @RequestMapping("/hello_world")
    public String helloWorld(Model model){
        model.addAttribute("msg","hello world");
        return "hello_springmvc";
    }

 After the configuration, you find access to other pages fails and this idea appears warning

 Cause: If there is no <mvc: annotation-driven />, then all @Controller annotations might not resolve all the processing request class when there is a request when they are not matched, go on <mvc: default-servlet-handler /> That default servlet handled.

 

 

Guess you like

Origin www.cnblogs.com/zy527/p/11705091.html