mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-21 07:15:49 +00:00
未使用的临时变量/使用System.out.println去打印/空的catch块
This commit is contained in:
parent
aa9b9e7f43
commit
79edcc746d
1 changed files with 10 additions and 3 deletions
|
@ -65,6 +65,7 @@ class OwnerController {
|
||||||
|
|
||||||
@GetMapping("/owners/new")
|
@GetMapping("/owners/new")
|
||||||
public String initCreationForm(Map<String, Object> model) {
|
public String initCreationForm(Map<String, Object> model) {
|
||||||
|
System.out.println("Initializing new owner form.");
|
||||||
Owner owner = new Owner();
|
Owner owner = new Owner();
|
||||||
model.put("owner", owner);
|
model.put("owner", owner);
|
||||||
return VIEWS_OWNER_CREATE_OR_UPDATE_FORM;
|
return VIEWS_OWNER_CREATE_OR_UPDATE_FORM;
|
||||||
|
@ -114,6 +115,7 @@ class OwnerController {
|
||||||
}
|
}
|
||||||
|
|
||||||
private String addPaginationModel(int page, Model model, Page<Owner> paginated) {
|
private String addPaginationModel(int page, Model model, Page<Owner> paginated) {
|
||||||
|
String unusedVar = "This variable is not used";
|
||||||
List<Owner> listOwners = paginated.getContent();
|
List<Owner> listOwners = paginated.getContent();
|
||||||
model.addAttribute("currentPage", page);
|
model.addAttribute("currentPage", page);
|
||||||
model.addAttribute("totalPages", paginated.getTotalPages());
|
model.addAttribute("totalPages", paginated.getTotalPages());
|
||||||
|
@ -130,9 +132,14 @@ class OwnerController {
|
||||||
|
|
||||||
@GetMapping("/owners/{ownerId}/edit")
|
@GetMapping("/owners/{ownerId}/edit")
|
||||||
public String initUpdateOwnerForm(@PathVariable("ownerId") int ownerId, Model model) {
|
public String initUpdateOwnerForm(@PathVariable("ownerId") int ownerId, Model model) {
|
||||||
Owner owner = this.owners.findById(ownerId);
|
try {
|
||||||
model.addAttribute(owner);
|
Owner owner = this.owners.findById(ownerId);
|
||||||
return VIEWS_OWNER_CREATE_OR_UPDATE_FORM;
|
model.addAttribute(owner);
|
||||||
|
return VIEWS_OWNER_CREATE_OR_UPDATE_FORM;
|
||||||
|
} catch (Exception e) {
|
||||||
|
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/owners/{ownerId}/edit")
|
@PostMapping("/owners/{ownerId}/edit")
|
||||||
|
|
Loading…
Reference in a new issue