你这个直接在取bean中的属性值
不就行了吗。或者是把bean封装起来直接给一个对象赋值就可以了!
不就行了吗。或者是把bean封装起来直接给一个对象赋值就可以了!
解决方案 »
- 灰常困惑。。。。。
- JSTL值可以传给JAVA吗
- spring 3.0 mvc 的问题!
- 使用JNDI能访问服务器的那些资源?
- js实现判断用户输入内容为0-100否则警告,请问该怎样写?
- ◤◤◤ jsp中FCKeditor的上传
- 怎样在jsp中生成oracle时间格式的时间?
- 各位帮帮忙吧,好急,好烦!!(我把最后50分拿出来了)
- 高分求救~
- 为什么jbuilder好用的程序,到tomcate(直接运行)不好用了?
- parent.document.getElementById("frame").style.height=document.body.scrollHeight;这句是什么时候意思啊?
- 一个简单的字符处理
2,<jsp:forward page="servlet的class名">
index.jsp 提交页面<html>
<head>
USE JAVABEAN !!!
</head>
<body>
<form action="requestBean.jsp" method="post">
Name:
<input type="text" name="name"><br>
IsMarried:
<input type="CheckBox" name="isMarried" value=ok><br>
What:
<input type="Radio" name="what" value=10><br>
Age:
<input type="text" name="age"><br>
<br>
<input type=submit>
</form> </body>
</html>
结果返回页面 requestBean.jsp<jsp:useBean scope="page" id="RequestBean1" class="ccmpack.RequestBean" />
<jsp:setProperty property="*" name="RequestBean1"/><hl>Form总的信息</hl>
<br><br>
Name:
<%= RequestBean1.getName() %><br>
What:
<%= RequestBean1.getWhat() %><br>
IsMarried:
<%= RequestBean1.isMarried() %><br>
Age:
<%= RequestBean1.getAge() %><br>
*
* 更改所生成类型注释的模板为
* 窗口 > 首选项 > Java > 代码生成 > 代码和注释
*/
public class RequestBean {private String strIsMarried,strWhat,strName,strAge;
private int intName,intAge,intWhat;
private boolean isMarried;public void setIsMarried(String s){
strIsMarried = new String(s.toString());
if(strIsMarried==null){
isMarried = false;
}else{
isMarried = true;
}
}
public void setWhat(String s){
strWhat = new String(s.toString()); try{
intWhat = ((Integer)Integer.valueOf(strWhat)).intValue();
}catch(NumberFormatException e){
intWhat = -1;
}
}
public void setName(String s){
strName = new String(s.toString());
try{
intName = ((Integer)Integer.valueOf(strName)).intValue();
}catch(NumberFormatException e){
intName = -1;
}
}
public void setAge(String s){
strAge = new String(s.toString());
String strAge1 = String.valueOf(Integer.parseInt(strAge) + 1);
String strAge2 =strAge1;
if(strAge1.length()<6){
for(int i=0;i < 6 - strAge1.length();i++)
{strAge2 = "0" + strAge2;
strAge = strAge2;}
}
strAge = strAge2; try{
intAge = ((Integer)Integer.valueOf(strAge)).intValue();
}catch(NumberFormatException e){
intAge = -1;
}
}
public boolean isMarried(){
return isMarried;
}
public String getName(){
return strName;
}
public String getWhat(){
return strWhat;
}
public String getAge(){
return strAge;
}
}