Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jsp/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
jsp中的脚本_Jsp_Struts2 - Fatal编程技术网

jsp中的脚本

jsp中的脚本,jsp,struts2,Jsp,Struts2,大家好,我经历了一个概念,如果在jsp中的scriptlet中创建了一个变量,那么它的作用域将是整个jsp页面。我试着写下面的代码 <%@ taglib prefix="s" uri="/struts-tags"%> <%! String[] parts= null; String sm=null;%> <s:iterator value="ServiceManagement"><br/><% sm=%><s:property/

大家好,我经历了一个概念,如果在jsp中的scriptlet中创建了一个变量,那么它的作用域将是整个jsp页面。我试着写下面的代码

<%@ taglib prefix="s" uri="/struts-tags"%>
<%! String[] parts= null;
String sm=null;%>

<s:iterator value="ServiceManagement"><br/><% sm=%><s:property/>
<% parts=sm.split(":");  %>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<s:checkbox fieldvalue=<%= parts[1] %>" theme="simple" name="service_management"/>
<%= parts[0] %></s:iterator>



您会发现它无法编译。

Scriptlet始终不是编写JSP的推荐方法。逻辑应该和表现分开。在你的行动中做所有这些事情;使用Struts2标记在JSP中打印结果;如果可能的话,请不要再使用scriptlet(99.9%的情况下是可能的)。前面我的问题需要完成..请现在看一下,如果可以,请帮助我。
<% sm=%>
sm=
parts= sm.split(":");