I have this html:
<html>
<body>
<form action="#" th:action="@{/}" th:object="${person}" method="post">
<select id="person" th:field="*{name}">
<option th:each="p : ${list}" th:value="${p.getName()}" th:text="${p.getName()}"></option>
</select>
<button type="submit">Find</button>
</form>
<form action="#" th:action="@{/test}" th:object="${test}" method="post">
<select th:fragment="test">
<option th:each="p : ${listTest}" th:value="${p.getName()}" th:text="${p.getName()}"></option>
</select>
</form>
<button type="submit">view</button>
</body>
And this web service:
@RequestMapping(value="/", method=RequestMethod.GET)
public String showForm(Person person, Model model) {
List<Person> list = new ArrayList<Person>();
Person p1 = new Person();
p1.setName("John");
p1.setAge(46);
Person p2 = new Person();
p2.setName("Helen");
p2.setAge(34);
list.add(p1);
list.add(p2);
model.addAttribute("list",list);
return "form";
}
@RequestMapping(value="/test", method=RequestMethod.GET)
public String showForm(Test test, Model model) {
List<Test> listTest = new ArrayList<Test>();
Test p11 = new Test();
p11.setName("test1");
Test p22 = new Test();
p22.setName("test2");
listTest.add(p11);
listTest.add(p22);
model.addAttribute("listTest",listTest);
return "form :: test";
}
@RequestMapping(value="/", method=RequestMethod.POST)
public String checkPersonInfo(Person person1) {
return "redirect:/test";
}
@RequestMapping(value="/test", method=RequestMethod.POST)
public String checkPersonInfo(Prueba prueba) {
return "redirect:/test";
}
I want show two selectors with all options, but I only do that first show all and second nothing, backward, o now, the selector 2 show good, but delete selector1.
The selector 2, show options when user pulse bottom
What is the problem??
Thank you very much!
Aucun commentaire:
Enregistrer un commentaire