我想在一个文本框里输入人名,可输入多个然后用逗号隔开,然后再用split函数截取出来人名,然后再在前台页面显示多条记录,一个人名一条记录!怎么写?谢谢各位!
解决方案 »
- 打开index.jsp页面的时候同时加载iframe中内容的问题
- 软件升级,数据库变动如何对比更新
- 有人熟悉ehcache吗,如果缓存文件很大 会有影响吗?
- struts 用户退出问题
- 在struts中我这样写为什么会抛出如下异常,谢谢
- java.lang.NoSuchMethodException的一种可能错误
- java 调用oracle 储存过程求救! 急!急!急!
- ant编译脚本的错误"Default target 'dist' does not exists in project"
- ●关于Struts!我只是想logic:iterate来循环显示我的列表
- 关于JMS的疑问,请帮忙
- 急,急,急。itext生成PDF乱码问题,求解
- 从数据库中取出一列值出来,类型为list<double> 然后将,list中的值取出来放到这个 double date[][]=new double[][]中
你前台就用,隔开嘛。
然后表单提交到后台...掉用String类的split(",")。分隔成一个String[]用request.setAttribute() 转到前台界面。。然后用JSTL的<c:forEach>进行迭代表示。
如果不需要经过后台。。可以设置一个按钮,当点击这个按钮的时候,获取他的时候,var Str = .document.getEle......().value();
str.split(",");
然后用js拼装DOM,
<html>
<head>
<script>
function a(){
var str = document.getElementById('id').value;
var s ="";
s=str.split(",");
alert(s[0]);
alert(s[1]);
for(var i=0;i<s.length;i++){
document.writeln(s[i]);
}
}
</script>
</head>
<body>
<input name="name" id="id" />
<input type="button" value="OK" onclick="a()">
</body>
</html>
差不多就这个意思 你自己改下
<html>
<head>
<script>
function a(){
var str = document.getElementById('id').value;
var s ="";
s=str.split(",");
alert(s[0]);
alert(s[1]);
for(var i=0;i<s.length;i++){
document.writeln(s[i]);
}
}
</script>
</head>
<body>
<input name="name" id="id" />
<input type="button" value="OK" onclick="a()">
</body>
</html>
传到后台!应该是现在后台把文本框里的内容request.set出来,然后用sqlit函数截取,然后再在后台写个if语句一个人名一个人名的提交!然后就在前台页面显示单个人名就显示一条记录!输入多个人名,前台显示几个人名的记录
<tr>
<td align="right">领用人员:</td>
<td><textarea name="getPerson" id="getPerson" class="input1" verify="领用人员|NotNull" style="width:197px;height:90px;">可选多人,分号隔开${getPerson}</textarea></td>
</tr>
<td align="right">领用人员:</td>
<td><textarea name="getPerson" id="getPerson" class="input1" verify="领用人员|NotNull" style="width:197px;height:90px;">可选多人,分号隔开${getPerson}</textarea></td>
</tr>前台有着条语句!然后就是后台了!
怎么没人帮忙了!!!!!
Dim TestArray() As String = Split(TestString)
' TestArray holds {"apple", "", "", "", "pear", "banana", "", ""}
Dim LastNonEmpty As Integer = -1
For i As Integer = 0 To TestArray.Length - 1
If TestArray(i) <> "" Then
LastNonEmpty += 1
TestArray(LastNonEmpty) = TestArray(i)
End If
Next
ReDim Preserve TestArray(LastNonEmpty)
' TestArray now holds {"apple", "pear", "banana"}
这段代码我也看不懂啊!
cMClothGetSchema.setGetPerson(Request.getString("getPerson"));
这是我得到的内容怎么用sqlit函数截取啊?多谢了!!!
Transaction trans = new Transaction();
CMClothGetSchema cMClothGetSchema = new CMClothGetSchema();
cMClothGetSchema.setValue(Request);
long id = NoUtil.getMaxID("CMID","GetID");
cMClothGetSchema.setId(id);
cMClothGetSchema.setBranchInnerCode(HopeUtil.getOrgBranchCode());
cMClothGetSchema.setGetPerson(Request.getString("getPerson"));
String.valueOf(Request.getString("getPerson"));
Split(expression[, delimiter[, count[, compare]]]);
cMClothGetSchema.setAddTime(new Date());
cMClothGetSchema.setAddUser(User.getUserName());
CMClothStockSchema cmClothStockSchema = new CMClothStockSchema();
QueryBuilder qb1 = new QueryBuilder("select clothName,id from CMClothStock where clothName='"+Request.getString("clothName")+"'");
DataTable dt1 = qb1.executeDataTable();
if(dt1!=null&& dt1.getRowCount() > 0){
cmClothStockSchema.setId(dt1.getLong(0, "id"));
cmClothStockSchema.fill();
cmClothStockSchema.setClothStock(cmClothStockSchema.getClothStock()-Request.getInt("getAmount"));
trans.add(cmClothStockSchema,Transaction.UPDATE);
}else{
cmClothStockSchema.setId(NoUtil.getMaxID("CMID","stockID"));
cmClothStockSchema.setClothName(Request.getString("clothName"));
cmClothStockSchema.setClothStock(Request.getInt("getAmount"));
cmClothStockSchema.setClothUnit(Request.getString("clothUnit"));
cmClothStockSchema.setAddTime(new Date());
cmClothStockSchema.setAddUser(User.getUserName());
trans.add(cmClothStockSchema, Transaction.INSERT);
}
trans.add(cMClothGetSchema, Transaction.INSERT);
if(trans.commit()){
this.Response.setLogInfo(1, "创建成功");
UserLog.log("Inter", "AddInter", "创建领用信息成功!", this.Request.getClientIP());
}else{
this.Response.setLogInfo(0, "创建失败");
UserLog.log("Inter", "AddInter", "创建领用信息失败!", this.Request.getClientIP());
}
}就在这段里面加啊!不会啊!
String person_name = request.getParameter("getPerson"); //得到前台传送过来的值
String[] person_name_split = person_name.trim().split(","); //分隔
request.setAttribute("person_name_split",person_name_split); //将分隔的数据暂存等待跳转
怎么用Form表单形式提交啊?
String person_name = Request.getString("getPerson");
String[] person_name_split = person_name.trim().split(","); 在这段代码之后提交
<tr>
<td align="right">领用人员:</td>
<td><textarea name="getPerson" id="getPerson" class="input1" verify="领用人员|NotNull" style="width:197px;height:90px;">可选多人,分号隔开${getPerson}</textarea></td>
<td><input type = "submit" value="提交"></td>
</tr>
</form>点了提交之后,form内涉及到的值会跳转到对应的java文件下等待接收,再加之上面给的代码
其中action可写路径,若有配置,可写配置名
好像不能用Form提交,那样的话和客户需求就不一样了!
谢谢各位!
就是你的前台想要传入后台的数据 ,把它放入表单form中,之后点击<input type = "submit" value="提交">,这是一个表单提交按钮,这一动作会将你表单中的信息传入到对应路径的文件的方法A下等待接收,在方法A中用request.getParameter("getPerson")方法,得到表单传送过来的name="getPerson"的textArea中的值,再对得到的值进行分隔,然后request.setAttribute("name",分隔后的保存人名的数组);
然后再跳转到之前的页面,得到该数组,循环输出值,可用嵌套java代码或是EL表达式
String person_name = Request.getString("getPerson");
String[] person_name_split = person_name.trim().split(","); 上面后台 ,下面jsp前台
<tr>
<td align="right">领用人员:</td>
<td><textarea name="getPerson" id="getPerson" class="input1" verify="领用人员|NotNull" style="width:197px;height:90px;">可选多人,分号隔开${getPerson}</textarea></td>
</tr>
这不就是连个去了吗?是这样吗?