24,923
社区成员
发帖
与我相关
我的任务
分享
# www.ab26.com
<VirtualHost 11.22.333.444:80>
ServerAdmin lo@lo.com
ServerName ab26.com
ServerAlias ab26.com www.ab26.com
DocumentRoot "D:/websites/www.ab26.com/ROOT"
Alias /mydl/ "D:/dl/"
<Directory "D:/websites/www.ab26.com/ROOT">
Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
<Location ~"/WEB-INF/">
AllowOverride None
deny from all
</Location>
<Directory "D:/dl">
Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
CustomLog "logs/www.ab26.com-access_2009.log" combined
ErrorLog "logs/www.ab26.com-error_2009.log"
JkLogFile "logs/www.ab26.com-jk-error_2009.log"
JkLogLevel error
DirectoryIndex default.htm index.htm default.jsp index.jsp
JkMountFile conf/extra/www.ab26.com.properties
</VirtualHost>
# w1.ab26.com
<VirtualHost 11.22.333.444:80>
ServerAdmin lo@lo.com
ServerName w1.ab26.com
ServerAlias w1.ab26.com
DocumentRoot "D:/websites/w1.ab26.com/ROOT"
<Directory "D:/websites/w1.ab26.com/ROOT">
Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
<Location ~"/WEB-INF/">
AllowOverride None
deny from all
</Location>
CustomLog "logs/w1.ab26.com-access_2009.log" combined
ErrorLog "logs/w1.ab26.com-error_2009.log"
JkLogFile "logs/w1.ab26.com-jk-error_2009.log"
JkLogLevel error
DirectoryIndex default.htm index.htm default.jsp index.jsp
JkMountFile conf/extra/w1.ab26.com.properties
</VirtualHost>
# w2.ab26.com
<VirtualHost 11.22.333.444:80>
ServerAdmin lo@lo.com
ServerName w2.ab26.com
ServerAlias w2.ab26.com
DocumentRoot "D:/websites/w2.ab26.com/ROOT"
<Directory "D:/websites/w2.ab26.com/ROOT">
Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
<Location ~"/WEB-INF/">
AllowOverride None
deny from all
</Location>
CustomLog "logs/w2.ab26.com-access_2009.log" combined
ErrorLog "logs/w2.ab26.com-error_2009.log"
JkLogFile "logs/w2.ab26.com-jk-error_2009.log"
JkLogLevel error
DirectoryIndex default.htm index.htm default.jsp index.jsp
JkMountFile conf/extra/w2.ab26.com.properties
</VirtualHost>
<Connector port="8109" connectionTimeout="10000" enableLookups="false" redirectPort="8443" protocol="AJP/1.3" />
<Connector port="8209" connectionTimeout="10000" enableLookups="false" redirectPort="8443" protocol="AJP/1.3" />
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
<init-param>
<param-name>config</param-name>
<param-value>struts-default.xml,struts-www.xml</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>*.do</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>*.jsp</url-pattern>
</filter-mapping>
<constant name="struts.locale" value="zh_CN" />
<constant name="struts.i18n.reload" value="true" />
<constant name="struts.i18n.encoding" value="UTF-8" />
<constant name="struts.action.extension" value="do" />
<constant name="struts.ui.theme" value="simple" />
<constant name="struts.multipart.maxSize" value="5000000" />
<package name="udFile" extends="struts-default">
<action name="doUpfile" class="com.httpUtils.Upfile" method="upload">
<interceptor-ref name="defaultStack">
<param name ="allowedTypes">image/bmp,image/png,image/gif,image/jpeg</param>
<param name="maximumSize">5000000</param>
</interceptor-ref>
<result name="input">selectFile.jsp</result>
<result name="success">previewFile.jsp</result>
</action>
</package>
package com.httpUtils;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
public class Upfile {
private static final long serialVersionUID = 1L;
private File myFile;
private String fileName;
private String contentType;
private String filePath;
public String upload(){
filePath = "upfiles/";
String yName = StringUtil.getDateTime(1);
String mdName = StringUtil.getDateTime(6);
String feName = StringUtil.getDateTime(9) + getFileExt();//获取当前时间,用来重命名上传的文件
RrscAction.createFolder(filePath);//创建不存的文件夹
filePath += yName +"/";
RrscAction.createFolder(filePath);
filePath += mdName +"/";
RrscAction.createFolder(filePath);
filePath += feName;
String realPath = RrscAction.getRealPath(filePath);
save2file(myFile,realPath);
return "success";
}
private String getFileExt(){
int pos = getFileName().lastIndexOf(".");//出错时,会提示getFileName()为null
if(-1<pos)
return getFileName().substring(pos);
else
return ".noExt";
}
private void save2file(File src,String nfp){
final int BUFFER_SIZE = 1024;
try{
File nf = new File(nfp);
InputStream in = null;
OutputStream out = null;
try{
in = new BufferedInputStream(new FileInputStream(src),BUFFER_SIZE);
out = new BufferedOutputStream(new FileOutputStream(nf),BUFFER_SIZE);
byte[] buffer = new byte[BUFFER_SIZE];
while(0<in.read(buffer))
out.write(buffer);
} finally {
if(null!=in)
in.close();
if(null!=out)
out.close();
}
} catch (Exception e){
e.printStackTrace();
}
}
public void setMyFile(File myFile){
this.myFile = myFile;
}
public void setMyFileFileName(String fileName) {
this.fileName = fileName;
}
public void setMyFileContentType(String fileType) {
this.contentType = fileType;
}
public void setFilePath(String filePath) {
this.filePath = filePath;
}
public File getMyFile(){
return myFile;
}
public String getFileName() {
return fileName;
}
public String getMyFileContentType() {
return contentType;
}
public String getFilePath() {
return filePath;
}
}
<s:form action="doUpfile" method="post" name="upFileForm" onsubmit="return check(this);" enctype="multipart/form-data">
<input name="myFile" type="file">
<input type="submit" name="Submit" value="上传" >
</s:form>