Pergunta

Thymeleaf a using a link to pass a hidden value is possible

i am tried but the value not get in the pagee..

<tr th:each="ts : ${standard}">
<a href="../school/create-division.html"  th:href="@{/school/CreateDivision.html}" >
 Add Division  <input type="hidden" name="sid" th:value="${ts.id}" /></a>

and in controller

 @RequestMapping(value = Array("/school/CreateDivision.html"))
    def createDivision(divisionModel: ModelMap,@RequestParam sid:Long): String ={
    var standardId=sid
    var division:List[Division]=divisionService.findDivisionByStandardId(standardId)
    val divList:java.util.List[Division] = ListBuffer(division: _*)     
    divisionModel.addAttribute("division",  divList) 
    "school/create-division"
    }

here sid got null pointer

i don'nt know it is posiible

please share your answers

By Mila

Foi útil?

Solução 2

You must put the whole stuff into a form and make a form-submit GET or POST isn't relevant. However I would use

<a href="../school/create-division.html"
   th:href="@{/school/CreateDivision.html(sid=${ts.id})}">Division</a>

This should work without extra forms.

Outras dicas

It will not work due to the fact that the tag sends get requests only. The sid parameter is a hidden input and will be transmitted only as part of a form post.

http://www.w3schools.com/tags/ref_httpmethods.asp

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top