jsp属性值尝试使用表达式形成属性值 [英] jsp attribute value-trying to use expressions to form attribute values

查看:30
本文介绍了jsp属性值尝试使用表达式形成属性值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在jsp中面临一个基本问题.我有一个jsp.有一个div元素是循环的一部分,因此x是一个计数器.我正在尝试类似下面的操作,但这不是有效的语法.

I am facing a basic problem in my jsp. I have a jsp. There is a div element that is part of a loop .So here x is a counter. I am trying something like below but this is not valid syntax.

<% for (int x =0; x <5; x++) { %> 
 <s:div theme="ajax" id = <%=x%>  
   <s:form>   
      <s:submit theme="ajax" targets = '<%=x%>' />     
   </s:form> 
 </s:div> 
< % } % > 

能请你帮忙吗?问题在于id =<%= x%>或targets ='<%= x%>'似乎是无效的语法.我的目标是让'id'属性和'targets'属性具有动态值(基于计数器'x'的值)

Could you please help? The problem is that id = <%=x%> or targets = '<%=x%>' seems to be invalid syntax. My goal is to have 'id' attribute and 'targets' attribute hold a dynamic value(based on value of counter 'x')

推荐答案

您应关闭第一个s:div并用引号将ID标记:<s:div theme="ajax" id="<%=x%>">

You should close the first s:div and mark the id with quotes : <s:div theme="ajax" id="<%=x%>">

这篇关于jsp属性值尝试使用表达式形成属性值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆