我正在开发一个简单的应用程序在春天mvc没有使用春天形式标签,目前我的工作是通过使用下面的代码,但为了理解目的我问这个问题。 我有两个支持豆类,我已经绑定到一个html <form>
标签,这在spring form标签中是不可能的。提交表单与弹出窗体标签
豆1
public class Interim {
private int interimId;
private BigDecimal amount;
private int interimCategory;
// setter n getter
}
豆2
public class Bcr {
private int bcrId;
private BigDecimal cashAmount;
private int interimCategory;
}
HTML表单
<form action="/interim" method="get">
<input type="text" name="amount" />
<input type="text" name="cashAmount" />
<input type="text" name="interimCategory" />
<button type="submit" name="Month" > month </button>
</from>
春天控制器
@Controller
public TestController {
@RequestMapping(value = "/interim", method = RequestMethod.GET)
public String interimInit(ModelMap map) {
map.addAttribute("interim",new Interim());
map.addAttribute("bcr",new Bcr());
return "interim";
}
/// on form submit
@RequestMapping(value = "/interim", method = RequestMethod.GET, params = "Month")
public String getMonthlyInterim(@ModelAttribute("bcr") Bcr b,ModelMap
modelMap,@ModelAttribute("interim") Interim in) {
}
当我提交表单的Spring MVC两种豆类设置interimCategory,
- 如何分辨春天不要设置的Bcr豆interimCategory?
- 这是在春季创建html表单的好方法吗?
您在窗体上使用POST方法,但是,您的控制器上只有GET方法 –
ops编辑,谢谢;-) –
您对窗体的操作是“/ test”,但您没有方法与RequestMethod的“/测试” –