Spring Mvc中Jsp也页面怎么会获取不到Controller中的数据
Jsp页面<body>${user}</body>Controller类@ControllerpublicclassGeneralController{@RequestM...
Jsp页面
<body>
${user}
</body>
Controller类
@Controller
public class GeneralController{
@RequestMapping(value="index",method=RequestMethod.GET)
public ModelAndView index_jsp(Model model){
System.out.println("1");
model.addAttribute("liming", "黎明你好");
return new ModelAndView("index");
}
@RequestMapping(value="login",method=RequestMethod.GET)
public ModelAndView login(@RequestParam(value="username")String username,Model model){
System.out.println("2"+username);
Map m=new HashMap();
m.put("user", username);
//model.addAttribute("user", username);
return new ModelAndView(getS(),m);
}
public String getS(){
return "login";
}
} 展开
<body>
${user}
</body>
Controller类
@Controller
public class GeneralController{
@RequestMapping(value="index",method=RequestMethod.GET)
public ModelAndView index_jsp(Model model){
System.out.println("1");
model.addAttribute("liming", "黎明你好");
return new ModelAndView("index");
}
@RequestMapping(value="login",method=RequestMethod.GET)
public ModelAndView login(@RequestParam(value="username")String username,Model model){
System.out.println("2"+username);
Map m=new HashMap();
m.put("user", username);
//model.addAttribute("user", username);
return new ModelAndView(getS(),m);
}
public String getS(){
return "login";
}
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询