1:jsf中,后台bean给jsp传值很常见也很容易
例
SearchBean 中:
public class SearchBean { private String media_name=""; public String getMedia_name() { return media_name; } public void setMedia_name(String media_name) { this.media_name = media_name; }
...
}
|
faces-config.xml文件中配置bean
<managed-bean> <managed-bean-name>serach</managed-bean-name> <managed-bean-class>admin.SearchBean</managed-bean-class> <managed-bean-scope>request</managed-bean-scope> </managed-bean>
|
JSP页面中使用
<h:outputText value="文件名称(必填):" style="width: 150px" /> <h:inputText value="#{search.media_name}" style="width:250px;"></h:inputText>
|
2:jsp向后台bean传值
例
JSP页面中:
<h:commandButton value="上传" actionListener="#{search.uploadFile}" styleClass="button"> <f:attribute name="attrname1" value="#{visitor.userId}" /> </h:commandButton>
|
在bean中:
public void uploadFile(ActionEvent ae) throws Exception{
user_name = (String) ae.getComponent().getAttributes().get("attrname1");
...
}
|
阅读(3163) | 评论(0) | 转发(0) |