我想在jsp页面里面用javascript定义一个数组来接受java传过来的数据怎么老是收不到数据,传一个字符串可以,传一个字符串数组就没数据了?
jsp页面
Java代码 [code="java"]
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
Insert title here
<br><br> var string = '<s:property value="sometext"/>';<br><br> var idx = 1;<br><br> function dosomething()<br><br> {<br><br> idx ++;<br><br> if (idx > 10) idx = 1; </p> <pre><code> document.all.txtarea.innerText = string[idx]; return false; } function dosomething1() { idx --; if (idx < 1) idx = 10; document.all.txtarea.innerText = string[idx]; return false; } </code></pre> <p>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
Insert title here
<br> var string = '<s:property value="sometext"/>';<br> var idx = 1;<br> function dosomething()<br> {<br> idx ++;<br> if (idx > 10) idx = 1;</p> <pre><code> document.all.txtarea.innerText = string[idx]; return false; } function dosomething1() { idx --; if (idx < 1) idx = 10; document.all.txtarea.innerText = string[idx]; return false; } </code></pre> <p>
[/code]
struts
[code="java"]
package com.jwl.exam;
import com.opensymphony.xwork2.ActionSupport;
@SuppressWarnings("serial")
public class testjs extends ActionSupport{
private String[] sometext={"dfslhk","fsdfsdf"};
public String[] getSometext() {
System.out.println("getSometext()");
return sometext;
}
public void setSometext(String[] sometext) {
this.sometext = sometext;
}
}
[/code]
只是粗略的试了一下 字符串可以 数组 不知道是哪里写错了 老是没有数据