CSS:限制图片最大宽度
img{max-width:800px;width:expression(this.width > 800 ? 800: true);height:auto;}
Wizzer's Blog
img{max-width:800px;width:expression(this.width > 800 ? 800: true);height:auto;}
HSSFWorkbook wb = new HSSFWorkbook();
OutputStream out = new FileOutputStream(“x.xls”);
wb.write(out);
out.close();
return new File(“x.xls”);
ByteArrayOutputStream out = new ……..;
wb………
out.close();
ByteArrayInputStream in = new ………..(out.toByte…);
return in;
/e/class/userfun.php
function currentPage($classid,$thisid){ global $class_r; $fr=explode('|',$class_r[$classid][featherclass]); $topbclassid=$fr[1]?$fr[1]:$classid;//取得第一级栏目id if ($topbclassid==$thisid) { echo "class='cur'"; } else { } }
头部模板:
<ul> <li <?php if(empty($GLOBALS[navclassid])){echo "class='cur'";} ?>><a id="nav-hover0" href="[!--news.url--]">首页</a></li> <?php $i=0; $path=""; ?> [e:loop={'select classid,classname,classpath,wburl from [!db.pre!]enewsclass where bclassid=0 order by classid',0,24,0}] <?php $i=$i+1; $path=$public_r[newsurl].$bqr[classpath]; if(!empty($bqr[wburl])){ $path=$bqr[wburl]; } ?> <li <?=currentPage($GLOBALS[navclassid],$bqr[classid])?>> <a id="nav-hover<?=$i?>" href="<?=$path?>" title="<?=$bqr[classname]?>" target="_self" ><?=$bqr[classname]?></a> </li> [/e:loop] </ul>
首先配置好运行环境:
其次修改nginx配置文件:
server { listen 80; server_name localhost; location ~ ^/bbs/.+\.php$ { alias E:/xuetang/cn/bbs; rewrite /bbs/(.*\.php?) /$1 break; fastcgi_index index.php; fastcgi_pass 127.0.0.1:9000; fastcgi_param SCRIPT_FILENAME E:/xuetang/cn/bbs$fastcgi_script_name; include fastcgi_params; } location ~ ^/bbs($|/.*) { alias E:/xuetang/cn/bbs/$1; index index.php index.html index.htm; } location / { root E:/xuetang/cn/www; index index.html index.htm; } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } location ~ \.php$ { root E:/xuetang/cn/www; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } }
注意虚拟目录配置要在根目录上面。。
/** * 发送post请求 * @param string $url 请求地址 * @param array $post_data post数据 * @return string */ function send_post($url, $post_data) { $ch = curl_init($url); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($ch, CURLOPT_POSTFIELDS,$post_data); curl_setopt($ch, CURLOPT_RETURNTRANSFER,true); curl_setopt($ch, CURLOPT_HTTPHEADER, array( 'Content-Type: application/json', 'Content-Length: ' . strlen($post_data)) ); return curl_exec($ch); } <?php header("Content-type: text/html; charset=utf-8"); include_once('../functions.php'); $send_msg="test";//发送内容 $data = array("openid" => "oXS2NuPCEB836NRMrsXXXXXX", "content" => $send_msg); $data_string = json_encode($data); echo send_post('http://XXX.cn/api/wx/push/custom/text?mykey=XXXXXX', $data_string); ?>
1、上传文件的文件池路径问题
upload.js
filePool : {
type : “cn.xuetang.common.file.FilePool”,
args : [“/temp/”, 2000]
}
将路径改到项目的路径下
public class FilePool extends NutFilePool {
public FilePool(String homePath, long size) {
super(webinfPath(homePath), size);
}
private static final String webinfPath(String str) {
return Mvcs.getServletContext().getRealPath(“/WEB-INF”)+str;
}
}
2、Nutz大字段缓存的问题
.nutz/tmp/dao
将 org.nutz.dao.jdbc.nutz_jdbc_experts.js 拷贝到项目类路径下,修改相应的配置,文件夹不冲突即可。
编写执行文件 job.sh
#!/bin/sh CLASSPATH=classes:lib/druid-1.0.1.jar:lib/htmlparser-1.6.jar:lib/log4j-1.2.17.jar:lib/mysql-connector-java-5.1.26-bin.jar:lib/nutz-1.b.50.jar:lib/ojdbc14.jar:lib/quartz-2.2.1.jar:lib/quartz-jobs-2.2.1.jar:lib/slf4j-api-1.6.6.jar:lib/slf4j-log4j12-1.6.6.jar:lib/sqljdbc4.jar:lib/commons-pool2-2.2.jar: #export CLASSPATH java -classpath $CLASSPATH cn.xuetang.job.MyJob &
赋予job.sh 执行权限
chmod a+x job.sh
后台执行,并把标准输出重定向,关闭终端仍在执行
nohup bash /home/work/ImageTask/job.sh > success.log 2>error.log &
输出在当前控制台,关闭该终端时,将退出启动的进程
/home/work/ImageTask/job.sh
每两分钟启动一次,关闭终端不影响任务
crontab -e
*/2 * * * * /home/work/ImageTask/job.sh > success.log 2>error.log &
<Context path=”” docBase=”/usr/local/tomcat8080/webapps/ROOT” reloadable=”true” sessionCookiePath=”/” sessionCookieName=”BB_SESSION”/>
更改SESSION名称。
常用命令
复制文件夹
cp -ri apache-tomcat-7.0.53 /usr/local/tomcat1
删除文件夹
rm -rf
解压文件
tar -xzvf apache-tomcat-7.0.53.tar.gz
安装C++编码环境
yum install -y gcc-c++
安装HTTP GZIP
yum install -y zlib-devel
后台运行
java -jar aaa.jarr &
kill 脚本
kill -15 `ps -ef|grep server.jar|grep -v grep |awk ‘{print $2}’`
/usr/local/nginx/sbin/nginx -t #测试配置
/usr/local/nginx/sbin/nginx
/usr/local/nginx/sbin/nginx -s stop #停止服务器
/usr/local/tomcat1/bin/startup.sh
/usr/local/tomcat2/bin/startup.sh
/usr/local/tomcat8080/bin/startup.sh
查看端口
netstat -an | grep 80
系统
# uname -a # 查看内核/操作系统/CPU信息 # head -n 1 /etc/issue # 查看操作系统版本 # cat /proc/cpuinfo # 查看CPU信息 # hostname # 查看计算机名 # lspci -tv # 列出所有PCI设备 # lsusb -tv # 列出所有USB设备 # lsmod # 列出加载的内核模块 # env # 查看环境变量
资源
# free -m # 查看内存使用量和交换区使用量 # df -h # 查看各分区使用情况 # du -sh <目录名> # 查看指定目录的大小 # grep MemTotal /proc/meminfo # 查看内存总量 # grep MemFree /proc/meminfo # 查看空闲内存量 # uptime # 查看系统运行时间、用户数、负载 # cat /proc/loadavg # 查看系统负载
磁盘和分区
# mount | column -t # 查看挂接的分区状态 # fdisk -l # 查看所有分区 # swapon -s # 查看所有交换分区 # hdparm -i /dev/hda # 查看磁盘参数(仅适用于IDE设备) # dmesg | grep IDE # 查看启动时IDE设备检测状况
网络
# ifconfig # 查看所有网络接口的属性 # iptables -L # 查看防火墙设置 # route -n # 查看路由表 # netstat -lntp # 查看所有监听端口 # netstat -antp # 查看所有已经建立的连接 # netstat -s # 查看网络统计信息
进程
# ps -ef # 查看所有进程 # top # 实时显示进程状态
用户
# w # 查看活动用户 # id <用户名> # 查看指定用户信息 # last # 查看用户登录日志 # cut -d: -f1 /etc/passwd # 查看系统所有用户 # cut -d: -f1 /etc/group # 查看系统所有组 # crontab -l # 查看当前用户的计划任务
服务
# chkconfig --list # 列出所有系统服务 # chkconfig --list | grep on # 列出所有启动的系统服务
程序
# rpm -qa # 查看所有安装的软件包
入口函数:
@At
public void downImage(@Param(“tvid”) int tvid, HttpServletResponse resp, HttpServletRequest req) {
}
使用Nutz文件池:
Globals.FILE_POOL= new NutFilePool(“~/tmp/myfiles”, 10);
源码:
int i = 0; File f = Globals.FILE_POOL.createFile(".zip"); ZipOutputStream out = new ZipOutputStream(new FileOutputStream(f.getAbsolutePath())); for (Weixin_image image : list) { i++; String filename = Strings.sNull(bbinfo.get(image.getUid())) + "_" + Strings.sNull(userinfo.get(image.getUid())) + "_" + i+".jpg"; String picurl = image.getPicurl(); if (!Strings.isBlank(image.getImage_url())) { picurl = image.getImage_url(); } URL url = new URL(picurl); try { URLConnection conn = url.openConnection(); InputStream inStream = conn.getInputStream(); byte[] buffer = new byte[1204]; out.putNextEntry(new ZipEntry(filename)); while ((byteread = inStream.read(buffer)) != -1) { bytesum += byteread; out.write(buffer, 0, byteread); } out.closeEntry(); inStream.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } out.close(); resp.setHeader("Content-Length", "" + f.length()); resp.setHeader("Content-Disposition", "attachment; filename=\"" + tvShow.getPlay_name() + ".zip\""); Streams.writeAndClose(resp.getOutputStream(), Streams.fileIn(f));