displaytag
1、安装
displaytag-1.2.jar
commons-lang-2.1.jar
commons-beanutils-1.8.0.jar
将这三个jar文件放到 WEB-INF/lib/ 下,并删除老版本的jar。
下载地址:
http://sourceforge.net/project/showfiles.php?group_id=73068
http://commons.apache.org/lang/
http://commons.apache.org/beanutils/
注意版本
2、使用
<%@ taglib uri="http://displaytag.sf.net" prefix="display" %>
<display: table name="list" pagesize="10" class="listcss">
<display:column property=" id" title="ID" sortable="true"></display:column>
<display:setProperty name="paging.banner.placement" value="botton"></display:setproperty>
</display:table>
mimetex + fckeditor
XP Tomcat6+mimetex 配置
1、下载 mimetex.exe 到 ....webapps\ROOT\WEB-INF\cgi-bin\
2、修改 $Tomct_PATH$\conf \ web.xml:
<servlet-name>cgi</servlet-name>
<servlet-class>org.apache.catalina.servlets.CGIServlet</servlet-class>
<init-param>
<param-name>clientInputTimeout</param-name>
<param-value>100</param-value>
</init-param>
<init-param>
<param-name>debug</param-name>
<param-value>6</param-value>
</init-param>
<init-param>
<param-name>cgiPathPrefix</param-name>
<param-value>WEB-INF/cgi-bin</param-value>
</init-param>
<init-param>
<param-name>executable</param-name>
<param-value>cmd /c </param-value>
</init-param>
<load-on-startup>5</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>cgi</servlet-name>
<url-pattern>/cgi-bin/*</url-pattern>
</servlet-mapping>
3、修改 $Tomcat_PATH$\conf \contex.xml
加入 privileged ="true“是为了防止出现 ...Servlet of class org.apache.servlets.CGIServlet is privileged and cannot be loaded by this web application ...的错误
4、找个 servlets-cgi.renametojar 改名为 servlets-cgi.jar 保存到 $Tomcat_PATH$\lib\
5、重启 tomcat
6、测试:
MyEclipse 编码
改变当前project编码:
File-->Properties-->Resource-->Text file encoding
改变Editor默认编码:
Window-->Preferences-->MyEclipse-->file and editors-->JSP: Encoding: 默认是 Chinese, National Standard( GB18030 ), 改为: ISO 10646/Unicode( UTF-8 )
改变project 默认编码:
Window-->Preferences-->Workspace-->Text file encoding : 默认是 Default ( GB18030 ), 改为: Other,选择 UTF-8 。
org.apache.commons.fileupload 路径
用org.apache.commons.fileupload 上传文件:
DiskFileUpload.setRepositoryPath(path)
FileItem.write( new File(fullpath)
上面两个方法的path 都是物理路径, (好像 jspsmartupload 是虚拟路径,但是这个已经不好找了,而且据说对中文文件有问题),如果要用虚拟路径的话,就需要用ServletContext中的getRealPath函数:
DiskFileUpload.setRepositoryPath(application.getRealPath(virtualpath))
FileItem.write( new File(application.getRealPath(virtualpath)+"/"+filename)
下面是个例子, 把上传的文件按原来的名字保存在 /upsave 下:
-
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
-
<%@ page import="org.apache.commons.fileupload.*" %>
-
<%@ page import="java.io.*" %>
-
<%@page import="org.apache.commons.io.*" %>
-
-
<%
-
DiskFileUpload diskfile = new DiskFileUpload();
-
-
diskfile.setSizeMax( 100*1024*1024 ); // 允许文件最大长度
-
-
diskfile.setSizeThreshold(4096); // 设置内存缓冲大小
-
-
diskfile.setRepositoryPath(application.getRealPath("/tmp"));
-
// 设置临时目录
-
List fileItems = diskfile.parseRequest(request);
-
Iterator iter = fileItems.iterator();
-
-
for( ; iter.hasNext(); ) {
-
-
FileItem fileItem = (FileItem) iter.next();
-
if( fileItem.isFormField() ) {
-
// 当前是一个表单项
-
out.println( fileItem.getFieldName() + "=" + fileItem.getString() );
-
}
-
else {
-
// 当前是一个上传的文件
-
String fileName = fileItem.getName();
-
String fname=fileName.substring(fileName.lastIndexOf("\\")+1); //取得文件名
-
if(fname!=null && !fname.trim().equals("")){
-
//是否有文件上传
-
fileItem.write( new File(application.getRealPath("/upsave")+"\\"+fname));
-
}
-
}
-
}
-
%>