package com.springmvc.helloworld_1;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
@RequestMapping(value="/example")
public class HelloWorld {
@RequestMapping("/helloworld")
public String hello(){
System.out.println("hello world");
return "success";
}
}
上面代码在类定义处指定映射为"/example",在hello()方法处指定为"/helloworld"。
那么hello()方法的URL映射地址为:http://localhost:8080/springMVC/example/helloworld
(注:springMVC为项目名称,即注解中定义在类上的url会在“/”前默认加上项目名称,在写页面跳转url是要注意)
我是菜鸟,记录下面自己犯的一个错误