在WBE-INF下创建veloctity.properties
内容如下input.encoding=UTF-8
output.encoding=UTF-8
import java.util.ArrayList;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.AbstractController;
@Controller
@RequestMapping("/user")
public class UserController {
@RequestMapping(value = "/getUser", method = RequestMethod.GET)
public ModelAndView getUser() {
ModelAndView mv = new ModelAndView();
mv.addObject("message", "Hello World!!!");
mv.setViewName("/hello");
return mv;
}
}
在view里面创建一个hello.jsp
${message}