struts新手请教! 是的.struts建议jsp页面上没有java代码.都要用标记. 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 如果想传参数到jsp中,可以这样写(比如你想将class A的一个实例传到jsp中显示):在action中A a=new A();a.setId(1);request.setAttribute("a",a);在jsp中<bean:write name="a" property="id"/>。这样就将实例a的id属性显示到jsp页面上了。同样对于forward想传参数你也应该知道怎么样做了吧。如果a是一个简单的数据(如String)就可以这样写:<bean:write name="a"/>。 那那个a对象不需要在formbean中定义吗?我指的是在struts-config.xml中formbean的定义 我来回答第4个吧 *_*页面上:<html:radio property="sex" value="male"><html:radio property="sex" value="female">form里:private String sex="";public String getSex(){return sex;}public void setSex(String s){this.sex=s;}这样前后就可以对照起来,页面数据和form数据应该是保持一致的ps:刚开始学struts,恳请大家狠劲地批评 *^o~* 1.如果功能能由Struts标签来实现的尽量去用它实现2.<bean:define name="A" id="a" property="id"/><logic:equal name="B" property="id" value="<%=a%>"><bean:write name="B" property="name"/></logic:equal>3.在Action中:String page =request.getParameter("strPage");ActionForward forward = new ActionForward("/admin/index.jsp?page="+strPage);4.页面上:<html:radio property="sex" value="male"><html:radio property="sex" value="female">form里:private String sex=null;public String getSex(){return sex;}public void setSex(String s){this.sex=s;}在查询Action中,假如你查询显示页面对应的ActionFormBean的名字是customer,从数据库中性别的代码是male,那么customer.setSex("male");request.setAttribute("customer",customer);return mapping.findForward("success"); struts模式中,jsp主要用于显示,action,actionform(servlet)用于控制数据,bean用于数据封装,逻辑控制.M-V-C各个层面分得越清楚,维护移植方面,也就越好.但完全做到这一点,不容易,也没必要. 第三个问题:<forward name="success" path="/admin/index.jsp?page=<%=String.valueOf(1)%>"/> Cnxiaowei:你这个贱货,从VB.NET区逃到这里来啦?可算被我找到了!你换ID吧! 一个数据库问题 一个白痴问题 急求~~~~~~ 图片URL替换 怎样在hibernate中用一个普通属性做外键 hibernate 动态构造对象实例问题********************* 关于JAVA 用webservice调用远程接口的问题! 高分求一个java的简单问题(数据库dump文件转xml). java绝对高手进 java编的application能在web上运行吗? SSM框架使用Ueditor怎样向后台传数据 请教:JAVA中有没有办法能直接访问内存地址, 关于weblogic中SessionBean能存活多长时间的问题??
在action中A a=new A();a.setId(1);request.setAttribute("a",a);
在jsp中<bean:write name="a" property="id"/>。这样就将实例a的id属性显示到jsp页面上了。同样对于forward想传参数你也应该知道怎么样做了吧。如果a是一个简单的数据(如String)就可以这样写:<bean:write name="a"/>。
页面上:
<html:radio property="sex" value="male">
<html:radio property="sex" value="female">form里:
private String sex="";
public String getSex(){return sex;}
public void setSex(String s){this.sex=s;}这样前后就可以对照起来,页面数据和form数据应该是保持一致的
ps:刚开始学struts,恳请大家狠劲地批评 *^o~*
2.<bean:define name="A" id="a" property="id"/>
<logic:equal name="B" property="id" value="<%=a%>">
<bean:write name="B" property="name"/>
</logic:equal>
3.在Action中:
String page =request.getParameter("strPage");
ActionForward forward = new ActionForward("/admin/index.jsp?page="+strPage);4.页面上:
<html:radio property="sex" value="male">
<html:radio property="sex" value="female">form里:
private String sex=null;
public String getSex(){return sex;}
public void setSex(String s){this.sex=s;}
在查询Action中,假如你查询显示页面对应的ActionFormBean的名字是customer,从数据库中性别的代码是male,那么
customer.setSex("male");
request.setAttribute("customer",customer);
return mapping.findForward("success");
<forward name="success" path="/admin/index.jsp?page=<%=String.valueOf(1)%>"/>