admin管理员组文章数量:1434909
I need to change (parse) one of the object property. Is it any way I can save the parse value in the js variable and then pass it back. This is what I tried but it does not work:
<c:forEach var="user" items="${requestScope.users}">
var parsedName= parseUserName("${user.name}");
<c:set target = "${user}" property = "parsedName" value ="${parsedName}"/>
</c:forEach>
I need to change (parse) one of the object property. Is it any way I can save the parse value in the js variable and then pass it back. This is what I tried but it does not work:
<c:forEach var="user" items="${requestScope.users}">
var parsedName= parseUserName("${user.name}");
<c:set target = "${user}" property = "parsedName" value ="${parsedName}"/>
</c:forEach>
Share
Improve this question
asked Nov 16, 2016 at 15:21
user5783530user5783530
2511 gold badge4 silver badges16 bronze badges
3
- This looks like XY Problem. Could you include information about a broader picture of the problem? – acm Commented Nov 16, 2016 at 15:30
- I need to show some user information in my html, but one of the field(name) has to be parsed first – user5783530 Commented Nov 16, 2016 at 15:31
- Add Hole case Scenario rather then just small glimpse of it. Include what you want to parse and how you want to parse and obviously that includes why... – Shalin Patel Commented Nov 17, 2016 at 12:22
3 Answers
Reset to default 2Your idea is:
<c:forEach var="user" items="${requestScope.users}">
<script type="javascript">
var parsedName= parseUserName("${user.name}");
</script>
<c:set target = "${user}" property = "parsedName" value ="${parsedName}"/>
</c:forEach>
unfortunately it is not possible.
The jstl
code happen on the server side and javascript on the client side.
No it is not possible to do what you are trying to do. The only possible solution is to send the variable to the server using a partial refresh and set the required property once the page has been refreshed
If possible try to implement the parseUserName() logic in JSP itself using JSTL.
If you need help with that post the JS method logic here.
本文标签: javaPass javascript variable to jstl tagsStack Overflow
版权声明:本文标题:java - Pass javascript variable to jstl tags - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745637480a2667645.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论