0
//controller
@RequestMapping("/view")
public String viewEmpDetails(@RequestParam int emp_Id,@ModelAttribute Employee emp,Model model){
emp=empService.getEmpDetails(emp_Id);
model.addAttribute("isView",true);
model.addAttribute("emp",emp);
model.addAttribute("readonly", true);
model.addAttribute("action","/getList");
return "employee";
}
//jsp page
<td>First Name <span style="color:red;">*</span>:</td>
<td><form:input id="firstName" path="firstName" value="${emp.firstName}" readonly="true" /></td>
<td><input type="text" id="firstNameError" style="visibility:hidden;color:red"></td>
</tr>
<tr>
<td>Last Name :</td>
<td><form:input id="lastName" path="lastName" value="${emp.lastName}" readonly="true" /></td>
<td><input type="text" id="lastNameError" style="visibility:hidden;color:red"></td>
</tr>
我只使用了1个jsp来执行视图,如何在spring中只读使用mvc
请检查下面的例子,让我们知道你是否发现任何问题。 还有一点不要使用窗体:输入标签它很难使用。使用简单的html 标签。 –