我想要一个包含两个单独表单的索引页面。它可以单独使用,但不能一起使用。
我的文件是这样的:
IndexController.java:
@Controller
public class indexController {
@Autowired
UserService userService;
@RequestMapping(value = "/index", method = RequestMethod.GET)
public String viewLogin(Model model) {
Admin adminForm = new Admin();
Graph chartGraph = new Graph();
model.addAttribute("adminForm", adminForm);
model.addAttribute("chartGraph", chartGraph);
return "index";
}
@RequestMapping(value = "/index", method = RequestMethod.POST)
public String processIn(@ModelAttribute("adminForm") Admin admin,
Model model) {
System.out.println("adminname: " + admin.getUsername());
System.out.println("password: " + admin.getPassword());
return "index";
}
@RequestMapping(value = "/graph", method = RequestMethod.POST)
public String processIn(@ModelAttribute("chartGraph") Graph graph,
Model model) {
System.out.println("height: " + graph.getAltezza());
System.out.println("weight: " + graph.getLarghezza());
return "index";
}
}
的index.jsp
有什么问题? 如果你需要其他档案问我。感谢。