EXT JS如何获取STORE的附加数据

zjreset 2011-09-26 05:31:19
比如:
var mainstore = Ext.create('Ext.data.Store', {
model: 'XXXXX',
proxy: {
type: 'ajax',
url : _url,
reader: {
type: 'json',
root: 'data',
参数1: 'value1',
参数2: 'value2',
参数3: 'value3'
}
},
autoLoad: true
});
我怎么样才能通过mainstore获取到参数1,2,3的值,感谢啦
...全文
365 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
wxf999 2011-09-28
  • 打赏
  • 举报
回复
mainstore.reader.参数1
wxf999 2011-09-28
  • 打赏
  • 举报
回复
mainstore.参数1
aj3423 2011-09-28
  • 打赏
  • 举报
回复
ext只是把ajax+loadData()封装成了.load()

个人偏向用Ajax请求拿到数据,store.loadData载入
好处是可以轻松拿到其他自定义数据,而不用hack进store.reader, 万一以后ext改了不放在reader里了 也不会受影响

zjreset 2011-09-27
  • 打赏
  • 举报
回复
简单来说,我现在可以通过_url从服务器端获取到Json数据:{"data":[data数据],"value1":"值1","value2":"值2","value3":"值3"},在store总通过root指定data可以获取到data结果集,但是我想获取到另外三个value,该怎么获取
一品 2011-09-27
  • 打赏
  • 举报
回复
不知道你要实现什么
zjreset 2011-09-27
  • 打赏
  • 举报
回复
没人气啊,都跑哪去了,过来看看啊
zjreset 2011-09-27
  • 打赏
  • 举报
回复
算了,还是用我的方法
zjreset 2011-09-27
  • 打赏
  • 举报
回复
回6,7楼,我怎么就获取不到reader呢
zjreset 2011-09-27
  • 打赏
  • 举报
回复
回5楼,你说的方法是取data结果集中的某个属性的值,我需要的是和data在同一级的其他属性的值,还是谢了
dataminer_2007 2011-09-27
  • 打赏
  • 举报
回复
this.reader.jsonData.value1
dataminer_2007 2011-09-27
  • 打赏
  • 举报
回复

this.getStore().load({
callback:function(r,options,success){
if(success == false) {
Ext.Msg.alert(msg_information,this.reader.jsonData.value1);
} else {
if(r.length == 0) {
Ext.Msg.alert(msg_information,msg_nodata_found);
}
}
}
});

试试在 callback 后获取, 具体的自己可以在 firebug 中调试
jsut_yi 2011-09-27
  • 打赏
  • 举报
回复
mainstore.getAt(索引).get('属性值')这样可以得 前提是mainstore.load()后
zjreset 2011-09-26
  • 打赏
  • 举报
回复
说明一下,json数据正常获取,获取的格式为:{"data":[data数据],"value1":"值1","value2":"值2","value3":"值3"},正常的Json格式数据,另外,我不想通过二层解析,也就是通过另外一个模型获取之后再分发相应的数据:data和value,系统通过比如获取totalProperty值的形式一次性获取,但是totalProperty也不知道怎么能显式的获取,不知道有没有这样的方法,先谢谢大家啦
Ex4.0共2个压缩包特性,《ext js权威指南》 前 言 第1章 ext js 4开发入门 / 1 1.1 学习ext js必需的基础知识 / 1 1.2 json概述 / 3 1.2.1 认识json / 3 1.2.2 json的结构 / 3 1.2.3 json的例子 / 4 1.2.4 在javascript中使用json / 4 1.2.5 在.net中使用json / 8 1.2.6 在java中使用json / 12 1.2.7 更多有关json的信息 / 15 1.3 ext js 4概述 / 15 1.4 ext js的开发工具的获取、安装与配置介绍 / 18 1.4.1 ext designer / 18 1.4.2 在visual studio中实现智能提示 / 23 1.4.3 spket / 28 1.4.4 在eclipse中实现智能提示 / 32 1.5 如何获得帮助 / 32 1.6 本章小结 / 33 .第2章 从“hello world”开始 / 34 2.1 获取ext js 4 / 34 2.2 配置使用ext js库 / 35 2.3 编写“hello world”程序 / 37 2.4 关于ext.onready / 38 2.5 关于ext.blank_image_url / 40 2.6 关于字体 / 42 2.7 ext js 4语法 / 42 2.8 本地化 / 60 2.9 为本书示例准备一个模板 / 60 2.10 本章小结 / 61 第3章 调试工具及技巧 / 62 3.1 使用firebug进行调试 / 62 3.2 在ie中调试 / 76 3.2.1 使用debugbar和companion.js调试 / 76 3.2.2 使用ietester测试 / 80 3.2.3 在ie 8或ie 9中调试 / 83 3.3 在chrome中调试 / 84 3.4 调试工具的总结 / 84 3.5 调试技巧 / 85 3.6 本章小结 / 89 第4章 ext js的基础架构 / 90 4.1 ext js框架的命名空间:ext / 90 4.1.1 概述 / 90 4.1.2 apply和applyif方法 / 90 4.1.3 不推荐的extend方法 / 92 4.1.4 数据及其类型检测 / 95 4.1.5 其他的基础方法 / 99 4.2 为框架顺利运行提供支持 / 107 4.2.1 平台检测工具:ext.is / 107 4.2.2 当前运行环境检测工具:ext.supports / 109 4.3 ext js的静态方法 / 112 4.3.1 概述 / 112 4.3.2 ext.object中的静态方法 / 113 4.3.3 ext.function中的静态方法 / 120 4.3.4 ext.array中的静态方法 / 127 4.3.5 ext.error中的静态方法 / 133 4.4 深入了解类的创建及管理 / 135 4.4.1 开始创建类 / 135 4.4.2 创建类的类:ext.class / 137 4.4.3 所有继承类的基类:ext.base / 151 4.4.4 实现动态加载:ext.loader / 151 4.4.5 管理类的类:ext.classmanager / 159 4.4.6 类创建的总结 / 161 4.5 动态加载的路径设置 / 163 4.6 综合实例:页面计算器 / 165 4.7 本章小结 / 169 第5章 ext js的事件及其应用 / 170 5.1 概述 / 170 5.2 浏览器事件 / 170 5.2.1 绑定浏览器事件的过程:ext.eventmanager / 170 5.2.2 封装浏览器事件:ext.eventobject / 179 5.2.3 移除浏览器事件 / 181 5.3 内部事件 / 184 5.3.1 内部事件对象:ext.util.event / 184 5.3.2 为组件添加事件接口:ext.util.observable / 188 5.3.3 为组件绑定事件 / 189 5.3.4 内部事件的触发过程 / 192 5.3.5 移除事件 / 194 5.4 特定功能的事件对象 / 196 5.4.1 延时任务:ext.util.delayedtask / 196 5.4.2 一般任务:ext.util.taskrunner与ext.taskmanager / 198 5.4.3 封装好的单击事件:ext.util.clickrepeater / 200 5.5 键盘事件 / 201 5.5.1 为元素绑定键盘事件:ext.util.keymap / 201 5.5.2 键盘导航:ext.util.keynav / 204 5.6 综合实例:股票数据的实时更新 / 205 5.7 本章小结 / 214 第6章 选择器与dom操作 / 215 6.1 ext js的选择器:ext.domquery / 215 6.1.1 选择器的作用 / 215 6.1.2 使用ext.query选择页面元素 / 215 6.1.3 基本选择符 / 223 6.1.4 属性选择符 / 229 6.1.5 css属性值选择符 / 234 6.1.6 伪类选择符 / 235 6.1.7 扩展选择器 / 248 6.1.8 ext.domquery的使用方法 / 249 6.1.9 ext js选择器的总结 / 252 6.2 获取单一元素:ext.dom.element / 252 6.2.1 从错误开始 / 252 6.2.2 使用ext.get获取元素 / 253 6.2.3 使用ext.fly获取元素 / 256 6.2.4 使用ext.getdom获取元素 / 257 6.2.5 获取元素的总结 / 258 6.3 元素生成器:ext.dom.helper / 258 6.3.1 概述 / 258 6.3.2 使用createhtml或markup方法生成html代码 / 258 6.3.3 使用createdom方法生成dom对象 / 261 6.3.4 使用createtemplate方法创建模板 / 263 6.3.5 helper对象的使用方法 / 263 6.4 元素的操作 / 273 6.5 获取元素集合:ext.compositeelementlite与ext.compositeelement / 277 6.5.1 使用ext.select获取元素集合 / 277 6.5.2 ext.dom.compositeelement与ext.dom.compositeelementlite的区别 / 279 6.5.3 操作元素集合 / 279 6.6 综合实例:可折叠的面板accordion / 280 6.7 本章小结 / 283 第7章 数据交互 / 284 7.1 数据交互基础 / 284 7.1.1 ajax概述 / 284 7.1.2 封装ajax:ext.data.connection与ext.ajax / 284 7.1.3 使用ajax / 291 7.1.4 跨域获取数据ext.data.jsonp / 295 7.1.5 为element对象提供加载功能:ext.elementloader / 295 7.1.6 为组件提供加载功能:ext.componentloader / 296 7.2 代理 / 299 7.2.1 代理概述 / 299 7.2.2 基本的代理:ext.data.proxy.proxy / 300 7.2.3 进行批量操作:ext.data.batch与ext.data.operation / 303 7.2.4 服务器端代理:ext.data.proxy.server / 305 7.2.5 使用ajax处理数据的代理:ext.data.proxy.ajax与ext.data.proxy.rest / 308 7.2.6 跨域处理数据的代理:ext.data.proxy.jsonp / 312 7.2.7 为ext.direct服务的代理:ext.data.proxy.direct / 312 7.2.8 客户端代理:ext.data.proxy.client / 314 7.2.9 从变量中提取数据的代理:ext.data.proxy.memory / 314 7.2.10 使用浏览器存储的代理:ext.data.webstorageproxy、ext.data. sessionstorageproxy和ext.data.proxy.localstorage / 314 7.3 读取和格式化数据 / 315 7.3.1 概述 / 315 7.3.2 数据的转换过程:ext.data.reader.xml、ext.data.reader.json和ext.data.reader.array / 315 7.3.3 reader对象的配置项 / 321 7.3.4 格式化提交数据ext.data.writer.writer、ext.data.writer.json和ext.data. writer.xml / 322 7.3.5 writer对象的配置项 / 325 7.4 数据模型 / 326 7.4.1 概述 / 326 7.4.2 数据类型及排序类型:ext.data.types与ext.data.sorttypes / 326 7.4.3 数据模型的骨架——字段:ext.data.field / 330 7.4.4 数据集:ext.util.abstractmixedcollection与ext.util.mixedcollection / 330 7.4.5 数据验证及错误处理:ext.data.validations与ext.data.errors / 332 7.4.6 模型的关系:ext.data.association、ext.data.hasmanyassociation和ext.data.belongstoassociation / 334 7.4.7 管理数据模型:ext.abstractmanager与ext.modelmanager / 336 7.4.8 定义数据模型:ext.data.model / 336 7.4.9 数据模型的定义过程 / 337 7.4.10 数据模型的创建 / 340 7.4.11 数据模型的配置项、属性和方法 / 343 7.5 store / 344 7.5.1 概述 / 344 7.5.2 store对象的实例化过程 / 345 7.5.3 treestore对象的实例化过程 / 348 7.5.4 ext.data.store加载数据的方法 / 350 7.5.5 ext.data.treestore加载数据的方法 / 354 7.5.6 store的配置项 / 358 7.5.7 store的分页 / 359 7.5.8 store的排序:ext.util.sorter与ext.util.sortable / 360 7.5.9 store的过滤:ext.util.filter / 363 7.5.10 store的分组:ext.util.grouper / 363 7.5.11 树节点:ext.data.nodeinterface与ext.data.tree / 364 7.5.12 store的方法 / 366 7.5.13 store的事件 / 368 7.5.14 store管理器:ext.data.storemanager / 369 7.6 综合实例 / 369 7.6.1 远程读取json数据 / 369 7.6.2 读取xml数据 / 378 7.6.3 store数据操作 / 379 7.7 本章小结 / 384 第8章 模板与组件基础 / 385 8.1 模板 / 385 8.1.1 模板概述 / 385 8.1.2 ext.template的创建与编译 / 385 8.1.3 格式化输出数据ext.string、ext.number、ext.date和ext.util.format / 389 8.1.4 超级模板:ext.xtemplate(包括ext.xtemplateparser和ext.xtemplatecompiler) / 393 8.1.5 模板的方法 / 396 8.2 组件的基础知识 / 396 8.2.1 概述 / 396 8.2.2 组件类的整体架构 / 397 8.2.3 布局类的整体架构 / 402 8.2.4 组件的创建流程 / 403 8.2.5 常用的组件配置项、属性、方法和事件 / 415 8.3 为组件添加功能 / 418 8.3.1 为元素添加阴影:ext.shadow与ext.shadowpool / 418 8.3.2 为组件提供阴影和shim功能:ext.layer / 419 8.3.3 让组件实现浮动功能:ext.util.floating / 420 8.3.4 记录组件状态:ext.state.stateful / 420 8.3.5 实现调整大小功能:ext.resizer.resizer与ext.resizer.resizetracker / 420 8.3.6 为组件提供拖动功能:ext.util.componentdragger / 421 8.3.7 为组件实现动画功能:ext.util.animate / 422 8.3.8 其他的组件辅助功能类 / 423 8.4 组件的管理 / 423 8.4.1 组件管理及查询:ext.componentmanager与ext.componentquery / 423 8.4.2 焦点管理:ext.focusmanager / 424 8.4.3 z-order管理:ext.zindexmanager与ext.windowmanager / 425 8.4.4 状态管理:ext.state.manager、ext.state.provider、ext.state.local-storageprovider和ext.state.cookieprovider / 426 8.5 综合实例 / 426 8.5.1 使用子模板 / 426 8.5.2 递归调用模板 / 428 8.6 本章小结 / 429 第9章 容器、面板、布局和视图 / 430 9.1 容器与布局的关系 / 430 9.2 容器 / 431 9.2.1 容器的创建过程:ext.container.abstractcontainer与ext.container.container / 431 9.2.2  ext.container.abstractcontainer和ext.container.container的配置项、属性、方法和事件 / 434 9.2.3 将body元素作为容器:ext.container.viewport / 435 9.3 面板 / 436 9.3.1 面板的结构 / 436 9.3.2 构件的放置:dockeditems / 438 9.3.3 面板标题栏构件:ext.panel.header与ext.panel.tool / 438 9.3.4 记录和恢复面板属性:ext.util.memento / 439 9.3.5 面板常用的配置项、方法和事件 / 439 9.4 布局 / 441 9.4.1 布局概述 / 441 9.4.2 布局的运行流程:ext.layout.layout / 441 9.4.3 容器类布局基类:ext.layout.container.container / 442 9.4.4 盒子布局、垂直布局与水平布局:ext.layout.container.box、ext.layout.container.vbox与ext.layout.container.hbox / 442 9.4.5 为盒子模型提供调整大小的功能:ext.resizer.splitter / 445 9.4.6 手风琴布局:ext.layout.container.accordion / 447 9.4.7 锚固布局:ext.layout.container.anchor / 448 9.4.8 绝对定位布局:ext.layout.container.absolute / 450 9.4.9 边框布局:ext.layout.container.border / 451 9.4.10 自动布局:ext.layout.container.auto / 453 9.4.11 表格布局:ext.layout.container.table / 454 9.4.12 列布局:ext.layout.container.column / 455 9.4.13 自适应布局:ext.layout.container.abstractfit与ext.layout.container.fit / 456 9.4.14 卡片布局:ext.layout.container.abstractcard与ext.layout.container.card / 456 9.5 标签面板 / 458 9.5.1 标签面板的构成及其运行流程:ext.tab.panel、ext.tab.bar与ext.tab.tab / 458 9.5.2 标签面板的配置项、属性、方法和事件 / 462 9.5.3 使用标签页 / 463 9.5.4 可重用的标签页 / 465 9.6 视图与选择模型 / 465 9.6.1 视图与选择模型概述 / 465 9.6.2 视图的运行流程:ext.view.abstractview与ext.view.view / 466 9.6.3 选择模型的工作流程 / 475 9.6.4 选择模型的配置项、属性、方法和事件 / 480 9.6.5 视图的配置项、属性、方法和事件 / 482 9.6.6 使用视图 / 484 9.7 页面布局设计 / 491 9.8 综合实例 / 492 9.8.1 布局设计实例:仿eclipse界面 / 492 9.8.2 在单页面应用中使用卡片布局实现“页面”切换 / 496 9.9 本章小结 / 498 第10章 重构后的grid / 500 10.1 grid的基类及其构成 / 500 10.1.1 概述 / 500 10.1.2 表格面板的运行流程:ext.panel.table / 500 10.1.3 表格视图的运行流程:ext.view.table与ext.view.tablechunker / 505 10.1.4 列标题容器的运行流程:ext.grid.header.container / 508 10.1.5 列标题的运行流程:ext.grid.column.column / 510 10.1.6 虚拟滚动条的工作原理:ext.grid.pagingscroller / 511 10.1.7 锁定列的运行流程:ext.grid.lockable与ext.grid.lockingview / 516 10.2 使用grid / 520 10.2.1 最简单的grid / 520 10.2.2 列的配置项 / 521 10.2.3 自定义单元格的显示格式 / 523 10.2.4 通过列对象定义单元格的显示格式 / 525 10.2.5 设置行的背景颜色 / 532 10.2.6 列标题的分组 / 533 10.2.7 使用锁定列 / 534 10.2.8 grid的配置项、属性、方法和事件 / 535 10.3 grid的附加功能 / 537 10.3.1 概述 / 537 10.3.2 附加功能基类:ext.grid.featrue.featrue / 537 10.3.3 为行添加附加信息:ext.grid.featrue.rowbody / 538 10.3.4 数据汇总功能:ext.grid.featrue.abstractsummary与ext.grid.featrue. summary / 539 10.3.5 分组功能:ext.grid.featrue.grouping / 543 10.3.6 分组汇总功能:ext.grid.featrue.groupingsummary / 545 10.4 可编辑的grid / 546 10.4.1 概述 / 546 10.4.2 grid实现可编辑功能的运行流程:ext.grid.plugin.editing / 547 10.4.3 单元格编辑的运行流程:ext.grid.plugin.cellediting、ext.grid.celleditor与ext.editor / 550 10.4.4 行编辑的运行流程:ext.grid.plugin.rowediting与ext.grid.roweditor / 556 10.4.5 在grid中使用单元格编辑模式 / 561 10.4.6 在grid中使用行编辑模式 / 562 10.4.7 grid编辑插件的配置项、属性、方法和事件 / 563 10.5 关于列表视图:listview / 564 10.6 属性grid / 564 10.6.1 概述 / 564 10.6.2 使用属性grid / 564 10.6.3 自定义编辑组件 / 565 10.6.4 propertygrid的配置项、属性、方法和事件 / 566 10.7 综合实例 / 567 10.7.1 使用不同选择模型的grid以及设置默认选择行 / 567 10.7.2 grid的本地排序和过滤 / 569 10.7.3 使用分页工具条(pagingtoolbar)实现远程分页、排序和过滤 / 570 10.7.4 使用分页滚动条(pagingscroller)实现远程分页、排序和过滤 / 574 10.7.5 使用cellediting实现数据的增删改 / 578 10.7.6 使用rowediting实现数据的增删改 / 587 10.7.7 主从表的显示 / 589 10.8 本章小结 / 595 第11章 与grid同源的树 / 597 11.1 树的构成 / 597 11.1.1 概述 / 597 11.1.2 树面板的运行流程:ext.tree.panel / 597 11.1.3 treestore的运行流程:ext.data.treestore / 600 11.1.4 treecolumn的运行流程:ext.tree.column / 602 11.1.5 视图的运行流程:ext.tree.view与ext.data.nodestore / 602 11.1.6 树的选择模型:ext.selection.treemodel / 603 11.2 树的使用 / 603 11.2.1 一个最简单的树 / 603 11.2.2 树节点的默认字段 / 603 11.2.3 为树节点添加附加字段 / 604 11.2.4 显示多列数据(treegrid效果) / 605 11.2.5 在树中使用复选框 / 605 11.2.6 树的配置项、属性、方法和事件 / 607 11.3 综合实例 / 608 11.3.1 树的远程加载 / 608 11.3.2 树的动态加载及节点维护 / 610 11.3.3 xml树及节点维护 / 617 11.3.4 使用树动态控制grid的显示 / 622 11.4 本章小结 / 625 第12章 表单 / 626 12.1 表单的构成及操作 / 626 12.1.1 表单面板的运行流程:ext.form.panel与ext.form.fieldancestor / 626 12.1.2 表单面板的配置项、属性、方法和事件 / 628 12.1.3 表单的管理:ext.form.basic / 629 12.1.4 basicform的配置项、属性、方法和事件 / 635 12.1.5 表单的操作:ext.form.action.action / 636 12.1.6 加载操作的运行流程:ext.form.action.load与ext.form.action.directload / 637 12.1.7 提交操作的运行流程:ext.form.action.submit、ext.form.action.directsubmit与ext.form.action.standardsubmit / 641 12.1.8 字段的构成 / 643 12.1.9 basefield的配置项、属性、方法和事件 / 643 12.1.10 常用的验证函数:ext.form.field.vtypes / 647 12.2 使用字段 / 647 12.3 使用trigger类字段 / 664 12.3.1 具有单击功能的字段:ext.form.field.trigger / 664 12.3.2 实现微调功能的spinner字段 / 665 12.3.3 使用numberfield字段 / 666 12.3.4 下拉选择类字段的基类:ext.form.field.picker / 667 12.3.5 使用datefield字段 / 667 12.3.6 使用timefield字段 / 669 12.4 使用combobox字段 / 669 12.4.1 概述 / 669 12.4.2 boundlist对象的运行流程 / 670 12.4.3 combobox字段的配置项、属性、方法和事件 / 671 12.4.4 最简单的combobox / 672 12.4.5 自定义列表显示格式的combobox / 673 12.4.6 动态调整combobox的列表数据 / 674 12.4.7 实现combobox的联动 / 676 12.4.8 使用combobox的查询功能 / 684 12.4.9 设置combobox的默认值 / 688 12.5 表单的验证和加载数据 / 690 12.5.1 表单的验证及错误显示方式 / 690 12.5.2 为表单加载数据 / 695 12.6 在表单中使用布局 / 701 12.6.1 分列显示表单的字段 / 701 12.6.2 使用fieldset作为列容器 / 703 12.6.3 使用两列布局加htmleditor的表单 / 704 12.6.4 在表单中使用标签页 / 705 12.7 综合实例:实现products表的管理功能 / 706 12.8 本章小结 / 715 第13章 窗口 / 716 13.1 窗口:ext.window.window. / 716 13.1.1 窗口的构成 / 716 13.1.2 窗口的配置项、属性、方法和事件 / 716 13.1.3 使用窗口 / 718 13.1.4 在窗口内使用布局 / 719 13.2 信息提示窗口:ext.window.messagebox / 720 13.2.1 概述 / 720 13.2.2 信息提示窗口的构成 / 720 13.2.3 使用信息提示窗口 / 722 13.2.4 信息提示窗口按钮的本地化 / 723 13.2.5 使用alert方法 / 724 13.2.6 使用confirm方法 / 724 13.2.7 使用progress方法 / 725 13.2.8 使用prompt方法 / 726 13.2.9 使用wait方法 / 727 13.2.10 使用信息提示窗口要注意的问题 / 727 13.3 综合实例:实现登录窗口 / 729 13.4 本章小结 / 733 第14章 按钮、菜单与工具条 / 734 14.1 按钮 / 734 14.1.1 按钮的构成:ext.button.button / 734 14.1.2 按钮的配置项、属性、方法和事件 / 734 14.1.3 使用按钮 / 736 14.1.4 带分割线的按钮:ext.button.split / 737 14.1.5 多状态按钮:ext.button.cycle / 737 14.1.6 按钮组:ext.container.buttongroup / 738 14.2 菜单及菜单项 / 739 14.2.1 ext js的菜单(menu对象)是什么 / 739 14.2.2 菜单管理器:ext.menu.manager / 740 14.2.3 菜单项:ext.menu.item / 740 14.2.4 可复选的菜单项:ext.menu.checkitem / 741 14.2.5 菜单分隔条:ext.menu.separator / 741 14.2.6 颜色选择器菜单:ext.menu.colorpicker / 742 14.2.7 日期选择菜单:ext.menu.datepicker / 742 14.2.8 使用菜单 / 742 14.3 工具栏及工具栏组件 / 743 14.3.1 工具栏:ext.toolbar.toolbar / 743 14.3.2 非交互式工具栏条目的基类:ext.toolbar.item / 743 14.3.3 文本项:ext.toolbar.textitem / 744 14.3.4 填充项:ext.toolbar.fill / 744 14.3.5 工具栏分隔条:ext.toolbar.separator / 744 14.3.6 空白项:ext.toolbar.spacer / 744 14.3.7 分页工具栏:ext.toolbar.paging / 744 14.3.8 使用工具栏 / 747 14.4 使用ext.action / 747 14.4.1 概述 / 747 14.4.2 action对象配置项和方法 / 748 14.4.3 使用示例 / 748 14.5 综合实例:在grid中使用右键菜单 / 750 14.6 本章小结 / 752 第15章 图形与图表 / 753 15.1 基础知识 / 753 15.1.1 svg简介 / 753 15.1.2 vml简介 / 754 15.2 图形介绍 / 755 15.2.1 概述 / 755 15.2.2 画布的工作流程:ext.draw.component / 755 15.2.3 图形引擎及接口:ext.draw.surface、ext.draw.engine.svg和ext.draw.engine.vml / 757 15.2.4 画笔:ext.draw.sprite / 760 15.2.5 图层:ext.draw.compositesprite / 760 15.2.6 调色板:ext.draw.color / 760 15.2.7 辅助对象:ext.draw.draw与ext.draw.matrix / 760 15.3 使用图形功能 / 760 15.3.1 简单的开始 / 760 15.3.2 drawcomponent对象的配置项、属性、方法和事件 / 761 15.3.3 surface对象的配置项、属性、方法和事件 / 761 15.3.4 drawsprite对象的配置项、属性、方法和事件 / 762 15.3.5 compositesprite对象的配置项、属性、方法和事件 / 763 15.3.6 使用基本图形 / 764 15.3.7 使用图片 / 765 15.3.8 使用路径 / 766 15.3.9 移动、旋转和缩放图形 / 767 15.3.10 使用渐变效果 / 770 15.3.11 使用图层 / 771 15.4 图表介绍 / 772 15.4.1 概述 / 772 15.4.2 图表的工作流程 / 773 15.5 使用图表 / 776 15.5.1 从一个简单例子开始 / 776 15.5.2 坐标轴的配置项 / 777 15.5.3 series对象的配置项、属性、方法和事件 / 779 15.5.4 折线图的配置项 / 780 15.5.5 显示多个折线图及使用图例 / 782 15.5.6 使用面积图 / 783 15.5.7 简单条形图(bar和column chart)及使用标签(label对象) / 785 15.5.8 堆积条形图 / 787 15.5.9 分组条形图 / 788 15.5.10 自定义条形颜色 / 789 15.5.11 使用散点图 / 789 15.5.12 使用饼图 / 791 15.5.13 自定义饼块颜色 / 792 15.5.14 使用表盘图 / 792 15.5.15 使用雷达图 / 795 15.5.16 使用时间轴 / 796 15.5.17 实现实时动态的图表 / 797 15.5.18 使用组合图 / 800 15.5.19 在图表中使用背景 / 801 15.5.20 在图表中自定义主题 / 803 15.6 本章小结 / 805 第16章 其他组件及实用功能 / 806 16.1 其他组件 / 806 16.2 使用滑块 / 812 16.3 使用提示信息 / 814 16.4 实用功能 / 822 16.5 本章小结 / 826 第17章 可简化通信的ext.direct / 827 17.1 准备工作 / 827 17.2 ext.direct的工作原理及构成 / 827 17.2.1 工作原理 / 827 17.2.2 ext.direct的构成 / 828 17.2.3 remotingprovider对象的具体工作流程 / 829 17.2.4 pollingprovider对象的具体工作流程 / 838 17.3 配置ext.direct的使用环境 / 839 17.3.1 概述 / 839 17.3.2 .net环境的配置 / 839 17.3.3 java环境的配置 / 842 17.4 使用ext.direct / 846 17.4.1 概述 / 846 17.4.2 使用directproxy及进行curd操作 / 846 17.4.3 使用ext.direct实现树的动态加载及节点维护 / 854 17.4.4 使用directload为表单加载数据 / 858 17.4.5 使用directsubmit提交表单及使用session / 863 17.4.6 使用ext.direct上传文件 / 866 17.4.7 使用pollingprovider对象 / 868 17.4.8 错误处理 / 871 17.5 本章小结 / 872 第18章 动画功能 / 873 18.1 动画功能的构成及工作流程 / 873 18.1.1 概述 / 873 18.1.2 动画功能的工作流程:ext.fx.anim / 874 18.1.3 分步动画的工作流程:ext.fx.animator / 877 18.2 使用动画 / 880 18.2.1 由最简单的动画开始 / 880 18.2.2 过渡效果使用的功能函数介绍 / 880 18.2.3 使用分步动画 / 882 18.2.4 注意的问题 / 883 18.3 在element对象中使用动画 / 883 18.4 本章小结 / 888 第19章 拖放功能 / 889 19.1 拖放功能的构成及工作流程 / 889 19.1.1 概述 / 889 19.1.2 dragdropmanager对象的工作流程 / 891 19.1.3 注册节点:ext.dd.registry / 893 19.1.4 一般拖动功能的工作流程:ext.dd.dd / 894 19.1.5 dragsource对象的工作流程 / 897 19.1.6 droptarget对象的工作流程 / 898 19.1.7 dragzone对象的工作流程 / 899 19.1.8 dropzone对象的工作流程 / 899 19.2 使用拖放功能 / 899 19.2.1 最简单的拖动效果 / 899 19.2.2 使用dragsource对象与droptarget对象 / 900 19.2.3 使用dragzone对象与dropzone对象(使用registry对象) / 902 19.2.4 使用dragzone对象与dropzone对象(不使用registry对象) / 903 19.2.5 通过拖动实现节点排序 / 904 19.2.6 使用gridviewdropzoneplugin插件 / 905 19.2.7 使用treeviewdragdropplugin插件 / 907 19.2.8 关于grid和tree拖动后的数据保存问题 / 910 19.3 本章小结 / 910 第20章 扩展与插件 / 911 20.1 扩展与插件的区别 / 911 20.2 扩展与插件如何选择 / 911 20.3 如何编写扩展 / 911 20.3.1 命名空间 / 911 20.3.2 定义扩展 / 912 20.3.3 定义别名 / 912 20.3.4 定义备用名 / 912 20.3.5 要求加载的类:requires与uses / 912 20.3.6 混入功能 / 913 20.3.7 构造函数与initcomponent方法 / 913 20.3.8 静态属性和方法与单件模式 / 913 20.3.9 可自动生成set和get方法的属性与initconfig方法 / 914 20.3.10 在扩展中常用的方法 / 914 20.3.11 编写扩展:treecombobox / 914 20.4 如何编写插件 / 920 20.4.1 概述 / 920 20.4.2 abstractplugin对象 / 921 20.4.3 插件的别名 / 921 20.4.4 编写插件:rowcolor / 922 20.5 扩展和插件介绍 / 923 20.5.1 概述 / 923 20.5.2 本地分页代理:ext.ux.data.pagingmemoryproxy / 923 20.5.3 标签滚动菜单:ext.ux.tabscrollermenu / 925 20.5.4 编辑器tinymce / 926 20.6 本章小结 / 928 第21章 主题开发 / 929 21.1 准备工作 / 929 21.1.1 安装ruby / 929 21.1.2 安装compass / 930 21.1.3 sass介绍 / 931 21.2 为ext js 4创建新主题 / 933 21.2.1 概述 / 933 21.2.2 目录结构 / 933 21.2.3 修改配置 / 933 21.2.4 编译 / 935 21.2.5 测试主题 / 935 21.3 通过ui配置项设置组件样式 / 937 21.4 本章小结 / 937 第22章 mvc应用架构 / 938 22.1 mvc应用架构的构成及工作流程 / 938 22.1.1 构成 / 938 22.1.2 控制器的工作流程:ext.app.controller / 938 22.1.3 application对象的工作流程 / 940 22.2 一步一步实现mvc框架 / 942 22.2.1 概述 / 942 22.2.2 创建目录 / 942 22.2.3 创建首页 / 942 22.2.4 创建启动脚本:app.js / 943 22.2.5 定义登录对话框 / 944 22.2.6 创建应用脚本:application.js / 948 22.2.7 创建viewport视图 / 949 22.2.8 菜单视图及控制器 / 950 22.2.9 实现订单管理 / 952 22.2.10 实现产品管理 / 958 22.2.11 示例效果 / 969 22.3 本章小结 / 970 附录 简写类名与ext js类名对照表 / 971
1 课程目标 学会使用腾讯提供的云开发功能快速开发后台 数据接口,用于存储小程序中用到的数据 学会使用小程序中常见的一些API,比如:分享小程序,拨打手机电话,地图位置等 掌握快速上架一款小程序需要的步骤 前端相关的css以及html,vue等基础不作为本课程的重点,本课程将提供一个基于图鸟UI修改的企业产品展示前端代码,我们在此基础上使用云开发实现页面数据动态化。由于本人是后端开发,对于前端样式等不擅长,所以基本都是直接复制现成的样式做简单的修改,想要学习前端html,css,js,vue等基础知识的小伙伴可以不必考虑本课程,B站以及其他平台有大量的免费课程。 2 课程内容 本课程将实现一个完整功能的企业产品展示小程序,之前有人找我开发一个农用拖拉机企业展示的小程序,说是要用云开发来做,正好我之前没用过云开发,都是自己搭建后端API以及管理后台来开发,因此想着一边开发一边录一个云开发的课程,帮助一些同学快速入门云开发,将包括一下内容: 首页 主要产品推荐 顶部铲平轮播图展示 中间产品分类 轮播消息通知 产品价格咨询 用户留下联系方式 全部产品列表展示 产品详细信息展示 用户估价咨询表单,用户向企业出售产品,类似厂家回收 个人中心 注册登录 询价记录 拨打企业电话 查看企业地址 查看企业工作时间 3 使用技术 vue2 uniapp 图鸟UI javascript 腾讯云开发 4 需要的开发工具 图鸟原始模板:https://ext.dcloud.net.cn/plugin?id=14378 hbuilder开发工具: https://www.dcloud.io/hbuilderx.html 微信开发者工具:https://developers.weixin.qq.com/miniprogram/dev/devtools/download.html
百度首页 | 百度空间 | 登录 广告停放提高网站流量,centos学习 主页博客相册|个人档案 查看文章
.htaccess怎么用2007-05-16 14:04(文章来源)http://www.dnpark.com.cn/news/mm/www/1179329504375ZKlMSgYr.html

Apache服务器的.htaccess是一个非常强大的分布式配置文件,学会使用.htaccess,对虚拟主机用户来说,可以实现众多的功能。这里有一篇很容易让人理解的.htaccess介绍,作为入门文章非常的适合。文章最初来自freewebmasterhelp.com,QiRan作了简单的中文翻译,我将加以完善。

Part 1 – Introduction介绍
Part 2 - .htaccess Commande命令
Part 3 - Password protection密码保护
Part 1 – Introduction介绍

Introduction 介绍

In this tutorial you will find out about the .htaccess file and the power it has to improve your website. Although .htaccess is only a file, it can change settings on the servers and allow you to do many different things, the most popular being able to have your own custom 404 error pages. .htaccess isn't difficult to use and is really just made up of a few simple instructions in a text file.
从本指南中,你将可以学习到有关.htaccess文件及其功能的知识,并用以优化你的网站。尽管.htaccess只是一个文件,但它可以更改服务器的设置,允许你做许多不同的事情,最流行的功能是您可以创建自定义的“404 error”页面。.htaccess 并不难于使用,归根结底,它只是在一个text文档中添加几条简单的指令而已。

Will My Host Support It? 我的主机支持它吗?

This is probably the hardest question to give a simple answer to. Many hosts support .htaccess but don't actually publicise it and many other hosts have the capability but do not allow their users to have a .htaccess file. As a general rule, if your server runs Unix or Linux, or any version of the Apache web server it will support .htaccess, although your host may not allow you to use it.
这可能很难用简单的答案来回答。许多主机支持.htaccess,但实际上并不会特别声明,许多其他类型的主机有能力但并不允许他们的用户使用.htaccess。一般来说,如果你的主机使用Unix或Linux系统,或任何版本的Apache网络服务器,从理论上都是支持.htaccess的,尽管你的主机服务商可能不允许你使用它。

A good sign of whether your host allows .htaccess files is if they support password protection of folders. To do this they will need to offer .htaccess (although in a few cases they will offer password protection but not let you use .htaccess). The best thing to do if you are unsure is to either upload your own .htaccess file and see if it works or e-mail your web host and ask them.
判断你的主机是否允许.htaccess,一个标志很好的是它是否支持文件夹密码保护。为达到此功能,主机服务商需要使用.htaccess(当然,少数情况下他们虽提供密码保护功能,但却并不允许你使用.htaccess)。如果你不确定自己的主机是否支持.htaccess,最好的办法是上传你自己的.htaccess文件看看是否有用,或者直接发送e-mail向你的主机服务商咨询。

What Can I Do? 我该怎么做?

You may be wondering what .htaccess can do, or you may have read about some of its uses but don't realise how many things you can actually do with it.
你可能疑惑.htaccess到底能做些什么,或者你可能曾知道它的一些功能但并不真正了解你实际到底可以用它来做多少事情。

There is a huge range of things .htaccess can do including: password protecting folders, redirecting users automatically, custom error pages, changing your file extensions, banning users with certian IP addresses, only allowing users with certain IP addresses, stopping directory listings and using a different file as the index file.
.htaccess可以做大量的事情,包括:文件夹密码保护、用户自动重定向、自定义错误页面、改变你的文件扩展名、封禁特定IP地址的用户、只允许特定IP地址的用户、禁止目录列表,以及使用其他文件作为index文件。

Creating A .htaccess File 创建一个.htaccess文档

Creating a .htaccess file may cause you a few problems. Writing the file is easy, you just need enter the appropriate code into a text editor (like notepad). You may run into problems with saving the file. Because .htaccess is a strange file name (the file actually has no name but a 8 letter file extension) it may not be accepted on certain systems (e.g. Windows 3.1). With most operating systems, though, all you need to do is to save the file by entering the name as:
创建.htaccess文件也许会给你带来一些困难。写文件很容易,你只需要在文字编缉器(例如:写字板)里写下适当的代码。真正困难的可能是文件的保存,因为.htaccess是一个古怪的文件名(它事实上没有文件名,只有一个由8个字母组成的扩展名),而在一些系统(如windows 3.1)中无法接受这样的文件名。在大多数的操作系统中,你需要做的是将文档保存成名为:

".htaccess"
(including the quotes). If this doesn't work, you will need to name it something else (e.g. htaccess.txt) and then upload it to the server. Once you have uploaded the file you can then rename it using an FTP program.
(包括引号)。如果这也不行,你需要将其先命名为其它名字(例如htaccess.txt),再将其上传到服务器上,之后直接使用FTP软件来重命名。

Warning 警告

Before beginning using .htaccess, I should give you one warning. Although using .htaccess on your server is extremely unlikely to cause you any problems (if something is wrong it simply won't work), you should be wary if you are using the Microsoft FrontPage Extensions. The FrontPage extensions use the .htaccess file so you should not really edit it to add your own information. If you do want to (this is not recommended, but possible) you should download the .htaccess file from your server first (if it exists) and then add your code to the beginning.
在使用.htaccess之前,我必须给你一些警告。虽然在服务器上使用.htaccess绝对不太可能给你带来任何麻烦(如果有些东西错了,它只是没效用罢了),但如果你使用Microsoft FrontPage Extensions,就必须特别小心。因为FrontPage Extensions本身使用了.htaccess,因此你不能编辑它并加入你自己的信息。如果确实有这方面的需要(并不推荐,但是可能),你应该先从服务器上下载.htaccess文档(如果存在),之后在前面加上你的代码。

Custom Error Pages 自定义错误页

The first use of the .htaccess file which I will cover is custom error pages. These will allow you to have your own, personal error pages (for example when a file is not found) instead of using your host's error pages or having no page. This will make your site seem much more professional in the unlikely event of an error. It will also allow you to create scripts to notify you if there is an error (for example I use a PHP script on Free Webmaster Help to automatically e-mail me when a page is not found).
我要介绍的.htaccess的第一个应用是自定义错误页面,这将使你可以拥有自己的、个性化的错误页面(例如找不到文件时),而不是你的服务商提供的错误页或没有任何页面。这会让你的网站在出错的时候看上去更专业。你还可以利用脚本程序在发生错误的时候通知你(例如我使用Free Webmaster Help的PHP脚本程序,当找不到页面的时候自动e-mail给我)。

You can use custom error pages for any error as long as you know its number (like 404 for page not found) by adding the following to your .htaccess file:
你所知道的任何页面错误代码(像404找不到页面),都可以通过在.htaccess文件里加入下面的文字将其变成自定义页面:

rrorDocument errornumber /file.html
For example if I had the file notfound.html in the root direct
ory of my site and I wanted to use it for a 404 error I would use:
举例来说,如果我的根目录下有一个nofound.html文件,我想使用它作为404 error的页面:

ErrorDocument 404 /notfound.html
If the file is not in the root directory of your site, you just need to put the path to it:
如果文件不在网站的根目录下,你只需要把路径设置为:

ErrorDocument 500 /errorpages/500.html
These are some of the most common errors:
以下是一些最常用的错误:

401 - Authorization Required 需要验证
400 - Bad request 错误请求
403 - Forbidden 禁止
500 - Internal Server Error 内部服务器错误
404 - Wrong page 找不到页面
Then, all you need to do is to create a file to display when the error happens and upload it and the .htaccess file.
接下来,你要做的只是创建一个错误发生时显示的文件,然后把它们和.htaccess一起上传。


Part 2 - .htaccess 命令

Introduction 介绍

In the last part I introduced you to .htaccess and some of its useful features. In this part I will show you how to use the .htaccess file to implement some of these.
在上一部分,我已经简单介绍了.htaccess以及它的一些有用功能,在这一部分,我将向你演示如何使用.htaccess文档去实现这些功能。

Stop A Directory Index From Being Shown 停示显示目录列表

Sometimes, for one reason or another, you will have no index file in your directory. This will, of course, mean that if someone types the directory name into their browser, a full listing of all the files in that directory will be shown. This could be a security risk for your site.
有些时候,由于某种原因,你的目录里没有index文件,这意味着当有人在浏览器地址栏键入了该目录的路径,该目录下所有的文件都会显示出来,这会给你的网站留下安全隐患。

To prevent against this (without creating lots of new 'index' files, you can enter a command into your .htaccess file to stop the directory list from being shown:
为避免这种情况(而不必创建一堆的新index文件),你可以在你的.htaccess文档中键入以下命令,用以阻止目录列表的显示:

Options -Indexes
Deny/Allow Certian IP Addresses 阻止/允许特定的IP地址

In some situations, you may want to only allow people with specific IP addresses to access your site (for example, only allowing people using a particular ISP to get into a certian directory) or you may want to ban certian IP addresses (for example, keeping disruptive memembers out of your message boards). Of course, this will only work if you know the IP addresses you want to ban and, as most people on the internet now have a dynamic IP address, so this is not always the best way to limit usage.
某些情况下,你可能只想允许某些特定IP的用户可以访问你的网站(例如:只允许使用特定ISP的用户进入某个目录),或者想封禁某些特定的IP地址(例如:将低级用户隔离于你的信息版面外)。当然,这只在你知道你想拦截的IP地址时才有用,然而现在网上的大多数用户都使用动态IP地址,所以这并不是限制使用的常用方法。

You can block an IP address by using:
你可以使用以下命令封禁一个IP地址:

deny from 000.000.000.000
where 000.000.000.000 is the IP address. If you only specify 1 or 2 of the groups of numbers, you will block a whole range.
这里的000.000.000.000是被封禁的IP地址,如果你只指明了其中的几个,则可以封禁整个网段的地址。如你输入210.10.56.,则将封禁210.10.56.0~210.10.56.255的所有IP地址。

You can allow an IP address by using:
你可以使用以下命令允许一个IP地址访问网站:

allow from 000.000.000.000
where 000.000.000.000 is the IP address. If you only specify 1 or 2 of the groups of numbers, you will allow a whole range.
被允许的IP地址则为000.000.000.000,你可以象封禁IP地址一样封禁整个网段。

If you want to deny everyone from accessing a directory, you can use:
如果你想阻止所有人访问该目录,则可以使用:

deny from all
but this will still allow scripts to use the files in the directory.
不过这并不影响脚本程序使用这个目录下的文档。

Alternative Index Files 替换index文件

You may not always want to use index.htm or index.html as your index file for a directory, for example if you are using PHP files in your site, you may want index.php to be the index file for a directory. You are not limited to 'index' files though. Using .htaccess you can set foofoo.blah to be your index file if you want to!
也许你不想一直使用index.htm或index.html作为目录的索引文件。举例来说,如果你的站点使用PHP文件,你可能会想使用index.php来作为该目录的索引文档。当然也不必局限于“index”文档,如果你愿意,使用.htaccess你甚至能够设置foofoo.balh来作为你的索引文档!

Alternate index files are entered in a list. The server will work from left to right, checking to see if each file exists, if none of them exisit it will display a directory listing (unless, of course, you have turned this off).
这些互为替换的索引文件可以排成一个列表,服务器会从左至右进行寻找,检查哪个文档在真实的目录中存在。如果一个也找不到,它将会把目录列表显示出来(除非你已经关闭了显示目录文件列表)。

DirectoryIndex index.php index.php3 messagebrd.pl index.html index.htm
Redirection 重定向

One of the most useful functions of the .htaccess file is to redirect requests to different files, either on the same server, or on a completely different web site. It can be extremely useful if you change the name of one of your files but allow users to still find it. Another use (which I find very useful) is to redirect to a longer URL, for example in my newsletters I can use a very short URL for my affiliate links. The following can be done to redirect a specific file:
.htaccess最有用的功能之一就是将请求重定向到同站内或站外的不同文档。这在你改变了一个文件名称,但仍然想让用户用旧地址访问到它时,变的极为有用。另一个应用(我发现的很有用的)是重定向到一个长URL,例如在我的时事通讯中,我可以使用一个很简短的URL来指向我的会员链接。以下是一个重定向文件的例子:

Redirect /location/from/root/file.ext
http://www.othersite.com/new/file/location.xyz
In this above example, a file in the root directory called oldfile.html would be entered as:
上述例子中,访问在root目录下的名为oldfile.html可以键入:

/oldfile.html
and a file in the old subdirectory would be entered as:
访问一个旧次级目录中的文件可以键入:

/old/oldfile.html
You can also redirect whole directoires of your site using the .htaccess file, for example if you had a directory called olddirectory on your site and you had set up the same files on a new site at: http://www.newsite.com/newdirectory/ you could redirect all the files in that directory without having to specify each one:
你也可以使用.htaccess重定向整个网站的目录。假如你的网站上有一个名为olddirectory的目录,并且你已经在一个新网站 http://www.newsite.com/newdirectory/上建立了与上相同的文档,你可以将旧目录下所有的文件做一次重定向而不必一一声明:

Redirect /olddirectory http://www.newsite.com/newdirectory
Then, any request to your site below /olddirectory will bee redirected to the new site, with the
extra information in the URL added on, for example if someone typed in:
这样,任何指向到站点中/olddirectory目录的请求都将被重新指向新的站点,包括附加的额外URL信息。例如有人键入:

http://www.youroldsite.com/olddirecotry/oldfiles/images/image.gif
They would be redirected to:
请求将被重定向到:

http://www.newsite.com/newdirectory/oldfiles/images/image.gif
This can prove to be extremely powerful if used correctly.
如果正确使用,此功能将极其强大。

Part 3 – 密码保护

Introduction 介绍

Although there are many uses of the .htaccess file, by far the most popular, and probably most useful, is being able to relaibly password protect directories on websites. Although JavaScript etc. can also be used to do this, only .htaccess has total security (as someone must know the password to get into the directory, there are no 'back doors')
尽管有各种各样的.htaccess用法,但至今最流行的也可能是最有用的做法是将其用于网站目录可靠的密码保护。尽管JavaScrip等也能做到,但只有.htaccess具有完美的安全性(即访问者必须知晓密码才可以访问目录,并且绝无“后门”可走)。

The .htaccess File 密码保护的.htaccess文件

Adding password protection to a directory using .htaccess takes two stages. The first part is to add the appropriate lines to your .htaccess file in the directory you would like to protect. Everything below this directory will be password protected:
利用.htaccess将一个目录加上密码保护分两个步骤。第一步是在你的.htaccess文档里加上适当的几行代码,再将.htaccess文档放进你要保护的目录下:

AuthName "Section Name"
AuthType Basic
AuthUserFile /full/path/to/.htpasswd
Require valid-user
There are a few parts of this which you will need to change for your site. You should replace "Section Name" with the name of the part of the site you are protecting e.g. "Members Area".
你可能需要根据你的网站情况修改一下上述内容中的一些部分,如用被保护部分的名字"Members Area",替换掉“Section Name”。

The /full/parth/to/.htpasswd should be changed to reflect the full server path to the .htpasswd file (more on this later). If you do not know what the full path to your webspace is, contact your system administrator for details.
/full/parth/to/.htpasswd则应该替换为指向.htpasswd文件(后面详述该文档)的完整服务器路径。如果你不知道你网站空间的完整路径,请询问一下你的系统管理员。

The .htpasswd File 密码保护的.htpasswd文件

Password protecting a directory takes a little more work than any of the other .htaccess functions because you must also create a file to contain the usernames and passwords which are allowed to access the site. These should be placed in a file which (by default) should be called .htpasswd. Like the .htaccess file, this is a file with no name and an 8 letter extension. This can be placed anywhere within you website (as the passwords are encrypted) but it is advisable to store it outside the web root so that it is impossible to access it from the web.
目录的密码保护比.htaccess的其他功能要麻烦些,因为你必须同时创建一个包含用户名和密码的文档,用于访问你的网站,相关信息(默认)位于一个名为.htpasswd的文档里。像.htaccess一样,.htpasswd也是一个没有文件名且具有8位扩展名的文档,可以放置在你网站里的任何地方(此时密码应加密),但建议你将其保存在网站Web根目录外,这样通过网络就无法访问到它了。

Entering Usernames And Passwords 输入用户名和密码

Once you have created your .htpasswd file (you can do this in a standard text editor) you must enter the usernames and passwords to access the site. They should be entered as follows:
创建好.htpasswd文档后(可以通过文字编辑器创建),下一步是输入用于访问网站的用户名和密码,应为:

username:password
where the password is the encrypted format of the password. To encrypt the password you will either need to use one of the premade scripts available on the web or write your own. There is a good username/password service at the KxS site which will allow you to enter the user name and password and will output it in the correct format.
“password”的位置应该是加密过的密码。你可以通过几种方法来得到加密过的密码:一是使用一个网上提供的permade脚本或自己写一个;另一个很不错的username/password加密服务是通过KxS网站,这里允许你输入用户名及密码,然后生成正确格式的密码。

For multiple users, just add extra lines to your .htpasswd file in the same format as the first. There are even scripts available for free which will manage the .htpasswd file and will allow automatic adding/removing of users etc.
对于多用户,你只需要在.htpasswd文档中新增同样格式的一行即可。另外还有一些免费的脚本程序可以方便地管理.htpasswd文档,可以自动新增/移除用户等。

Accessing The Site 访问网站

When you try to access a site which has been protected by .htaccess your browser will pop up a standard username/password dialog box. If you don't like this, there are certain scripts available which allow you to embed a username/password box in a website to do the authentication. You can also send the username and password (unencrypted) in the URL as follows:
当你试图访问被.htaccess密码保护的目录时,你的浏览器会弹出标准的username/password对话窗口。如果你不喜欢这种方式,有些脚本程序可以允许你在页面内嵌入username/password输入框来进行认证,你也可以在浏览器的URL框内以以下方式输入用户名和密码(未加密的):

http://username:password@www.website.com/directory/
Summary 小结

.htaccess is one of the most useful files a webmaster can use. There are a wide variety of different uses for it which can save time and increase security on your website.
.htaccess是一个站点管理员可以应用的强大工具,有更多的变化以适应不同的用途,可以节约时间及提高网站的安全性。

相关阅读:


KxS Password Encrypter
Apache .htaccess Documentation
More .htaccess Sites
Related Reading

.htaccess的特别说明


启用.htaccess,需要修改httpd.conf,启用AllowOverride,并可以用AllowOverride限制特定命令的使用
如果需要使用.htaccess以外的其他文件名,可以用AccessFileName指令来改变。例如,需要使用.config ,则可以在服务器配置文件中按以下方法配置:

AccessFileName .config
一般情况下,不应该使用.htaccess文件,除非你对主配置文件没有访问权限。有一种很常见的误解,认为用户认证只能通过.htaccess文件实现,其实并不是这样,把用户认证写在主配置文件中是完全可行的,而且是一种很好的方法。.htaccess文件应该被用在内容提供者需要针对特定目录改变服务器的配置而又没有root权限的情况下。如果服务器管理员不愿意频繁修改配置,则可以允许用户通过.htaccess文件自己修改配置,尤其是ISP在同一个机器上运行了多个用户站点,而又希望用户可以自己改变配置的情况下。虽然如此,一般都应该尽可能地避免使用.htaccess文件。任何希望放在.htaccess文件中的配置,都可以放在主配置文件的段中,而且更高效。避免使用.htaccess文件有两个主要原因,即性能和安全。


类别:php+mysql+apache+zend | 添加到搜藏 | 浏览(40) 网友评论: 发表评论:姓 名: 注册 | 登录 *姓名最长为50字节

网址或邮箱: (选填)

内 容:

验证码: 请输入下图中的四位验证码,字母不区分大小写。
看不清?




©2007 Baidu

52,797

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 Ajax
社区管理员
  • Ajax
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧