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 標籤。 –