topic01 jQuery和easyui
easyui
class=”easyui-linkbutton selectItemCat”:
easyui-linkbutton控件 selectItemCat动态事件绑定
【重要】
文件搜索:在全项目中文件搜索 因为jsp都是用的片段、组装形式
jQuery
页面初始化完毕之后:
$(function(){
});
js全局对象:
var E3={
kv形式封装一些方法
}
使用的时候:
E3.init(data): 直接调用
遍历:
$(“.xxx”).each(function(i,e){
})
i,当前循环
e,循环到的原生dom对象:
var _e = $(e)先包装
_e.after(“some html like ”);
_e.unbind(‘clike’).click(function(){}); 解绑再绑定
.window({})打开一个窗口,里面有一些kv形式的关于窗口的外在信息
,modal,还有绑定事件函数,如onOpen:function(){}
$().tree({kv})初始化一个tree,easyui的树形控件
kv:json对象,一些属性:
url初始化树的请求链接,接受json,要求见手册
关键是state:关闭或展开
为了json创建pojo(见前一天注意事项,如install,序列化等)
EasyUITreeNode
id(long),text,state
编写服务层、表现层相关代码
@RequestParam添加到controller方法的参数名称前面 解决请求参数和
方法参数名不一致以及添加默认值的问题
().parent().find({“name=cid”).val(node.id) 回写表单().next().text(node.text)继续写
$().window(‘close’)关闭窗口
topic02 图片上传功能:
怎么访问图片 ?
访问图片需要通过http协议:需要http静态资源服务器:nginx
怎么保存图片?
FastDFS 分布式储存系统 解决存储空间扩容
nginx:
http服务器;虚拟主机;反向代理,负载均衡
安装nginx
yum install gcc-c++
yum install -y pcre pcre-devel
yum install -y zlib zlib-devel
yum install -y openssl-devel
configure 生成makefile:
./configure \
–prefix=/usr/local/nginx \
–pid-path=/var/run/nginx/nginx.pid \
–lock-path=/var/lock/nginx.lock \
–error-log-path=/var/log/nginx/error.log \
–http-log-path=/var/log/nginx/access.log \
–with-http_gzip_static_module \
–http-client-body-temp-path=/var/temp/nginx/client \
–http-proxy-temp-path=/var/temp/nginx/proxy \
–http-fastcgi-temp-path=/var/temp/nginx/fastcgi \
–http-uwsgi-temp-path=/var/temp/nginx/uwsgi \
–http-scgi-temp-path=/var/temp/nginx/scgi
make
make install(安装,按照Makefile的指定目录安装)
usr/local/nginx
conf html sbin
sbin ./nginx 启动失败:
创建目录mkdir /var/temp/nginx -p
查看进程 ps -aux | grep nginx
./nginx -s stop
./nginx -s quit 停止服务
./nginx -s reload 热加载 刷新配置文件
配置nginx:配置虚拟主机,通过端口,通过域名
/usr/local/nginx/conf/nginx.conf
配置nginx反向代理 /usr/local/nginx/conf/nginx.conf
upstream tomcat1 {
server 192.168.230.100:8080;
}
server {
listen 80;
server_name www.sina.com.cn;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
proxy_pass http://tomcat1;
index index.html index.htm;
}
}
upstream tomcat2 {
server 192.168.230.100:8081;
}
server {
listen 80;
server_name www.sohu.com;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
proxy_pass http://tomcat2;
index index.html index.htm;
}
}
配置nginx 负载均衡 /usr/local/nginx/conf/nginx.conf
upstream tomcat2 {
server 192.168.230.100:8081;
server 192.168.230.100:8082 weight=2;
}
配置nginx高可用 + keepalived
VIP绑定到可用的(正常是主服务器)服务器
心跳检查
看安装手册就好
=======================================================
tomcat为什么要改三个端口号?
哪三个?
8005==》8006 security listener
8080==》8081 http访问端口
8009==》8010 ajp 1.3 connector
拓展:
**lvs入口 四层负载 传输层 请求转发
nginx 七层负载 应用层