1
간단하게 등록했습니다. 여기 컨트롤러두 콩의 데이터를 JSP로 가져 오기
<form class="form-horizontal" method="post" action="RightsGroupRegister">
<div class="form-group">
<label for="Name of group" class="col-sm-2 control-label">Name of group:</label>
<div class="col-sm-10">
<input class="form-control" id="name" name="name" placeholder="Name of group">
</div>
</div>
<div class="form-group">
<label for="Rights" class="col-sm-2 control-label">Rights:</label>
<div class="col-sm-10">
<input class="form-control" id="rights" name="rights" placeholder="Rights">
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<button class="btn btn-default">Create</button>
</div>
</div>
</form>
그리고 :
@Controller
public class RightsGroupController {
private static final Logger LOGGER = LoggerFactory.getLogger(RightsGroupController.class);
private final RightsGroupService rightsGroupService;
@Inject
public RightsGroupController(RightsGroupService rightsGroupService) {
this.rightsGroupService = rightsGroupService;
}
@RequestMapping(value = "RightsGroupRegister", method = RequestMethod.GET)
public ModelAndView getRightsGroupView() {
LOGGER.debug("Received request for addRight");
return new ModelAndView("RightsGroupRegister", "form", new RightsGroupForm());
}
@RequestMapping(value = "RightsGroupRegister", method = RequestMethod.POST)
public String createRightsGroup(@ModelAttribute("form") RightsGroupForm form) {
LOGGER.debug("Received request to create {}, with result={}", form);
try {
rightsGroupService.save(new Rightsgroup(form.getName(),form.getRights()));
} catch (RightsGroupAlreadyExistsException e) {
LOGGER.debug("Tried to create rightsgroup with existing id", e);
return "right_create";
}
return "redirect:/";
}}
지금 문제, 정말 그것을 작동하는 방법을 이해 해달라고 여기
내 JSP 레지스터 페이지의 일부입니다. 다른 개체에서이 양식 데이터를 가져 오는 방법은 무엇입니까? 예를 들어 권리 (id, name)의 목록?
무엇을 의미합니까? 'RightsGroupForm'의 필드에 접근하고 싶습니까? 당신이 이미 그것을하고있는 것처럼 보입니다. –
개체에서 데이터를 채우기 표 또는 콤보 상자를 채우려면 오른쪽 –
해결 했습니까? 내 안사가 도와 줬어? –