首页 > 代码库 > ExtJs treepanel和TabPanel配合使用
ExtJs treepanel和TabPanel配合使用
tree.js
Ext.onReady(function() { Ext.lib.Ajax.defaultPostHeader += '; charset=utf-8'; var center = new Ext.TabPanel( { id : 'tab_main', region : 'center', frame : false, items : [ { id : 'welcome', title : '首页', html : "<iframe src=http://www.mamicode.com/'welcome.jsp' width='100%' height='100%' frameboder='0' srcolling='auto''/>">
index.html<html> <head> <meta charset="UTF-8"> <title>Insert title here</title> <link rel="stylesheet" type="text/css" href=http://www.mamicode.com/"ext/resources/css/ext-all.css" />>TreeAction.javapackage com.lin.action; import java.io.PrintWriter; import javax.servlet.http.HttpServletResponse; import org.apache.struts2.ServletActionContext; import com.opensymphony.xwork2.ActionSupport; public class TreeAction extends ActionSupport { private String node; public String getNode() { return node; } public void setNode(String node) { this.node = node; } @Override public String execute() throws Exception { HttpServletResponse response = ServletActionContext.getResponse(); response.setContentType("text/json; charset=utf-8"); PrintWriter pw = response.getWriter(); System.out.println(node); if ("root".equals(node)) { pw.append("[{id:'module1',text:'模块1',leaf:false},{id:'module2',text:'模块2',leaf:true,url:'module2.jsp'}]"); } else { pw.append("[{id:'module3',text:'模块3',leaf:true,url:'module3.jsp'}]"); } pw.flush(); pw.close(); return NONE; } }实现效果:
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。