apache与tomcat共同处理同一个文件夹下的文件

apache与tomcat共同处理同一个文件夹下的文件,第1张

通过jk插件配置要转发给tomcat的url,tomcat的server.xml里面配置了两个连接器,8080端口是http连接器,8009是AJP连接器,这个就侍渗是与其它http服务器连接的。

将jk插件,linux下为mod_jk_linux.so(见附件),将其复制到<APACHE_HOME>/modules下,创建<APACHE_HOME>/conf/workers.properties,worker1 就是tomcat(tomcat的AJP连接器配置的是8009,这边也配置成8009,两个人就可以通信拉

worker.list=worker1

worker.worker1.port=8009  #工作端口,若没袭举占用则不用修改

worker.worker1.host=localhost  #Tomcat服务器的地址

worker.worker1.type=ajp13  #类型

worker.worker1.lbfactor=1  #负载平衡因数

修改<APACHE_HOME>/conf/httpd_modify.conf,在其末尾加入以下内容老禅脊

LoadModule jk_module modules/mod_jk_linux.so

JkWorkersFile conf/workers.properties

JkLogFile logs/mod_jk.log

JkLogLevel debug

JkMount /*.jsp worker1

JkMount /helloapp/* worker1

这最后两行的意思是如果是/helloapp/*下的所有访问,都交给tomcat处理,所有jsp也交给tomcat处理,你可以按自己的需要进行修改

stem.out.println("size limit exception!")

} catch(Exception e) { e.printStackTrace()

} Iterator iter = items==null?null:items.iterator()

while(iter != null &&

iter.hasNext()) { FileItem item = (FileItem)iter.next()

//简单的表单域 if(item.isFormField()) { System.out.print("form field:")

System.out.print(item.getFieldName() + " ")

System.out.print(item.getString())

} //文件域 else if(!item.isFormField()) { System.out.println("client name:" + item.getName())

String fileName = item.getName().substring(item.getName().lastIndexOf("\\"))

BufferedInputStream in = new BufferedInputStream(item.getInputStream())

//文件存储在工程的upload目录下,这个目录也得存在 BufferedOutputStream out = new BufferedOutputStream( new FileOutputStream(new File("../webapps/fileupload/upload/" + fileName)))

Streams.copy(in, out, true)

} } } else { System.out.println("enctype error!")

} } }

因为使用tomcat做得服务器,所以里面的路径都是以tomcat为基础来写得,具体情况需要历碧修改。

stem.out.println("size limit exception!")

} catch(Exception e) { e.printStackTrace()

} Iterator iter = items==null?null:items.iterator()

while(iter != null &&

iter.hasNext()) { FileItem item = (FileItem)iter.next()

//简单的表单域 if(item.isFormField()) { System.out.print("form field:")

System.out.print(item.getFieldName() + " ")

System.out.print(item.getString())

} //文件域 else if(!item.isFormField()) { System.out.println("client name:" + item.getName())

String fileName = item.getName().substring(item.getName().lastIndexOf("\\"))

BufferedInputStream in = new BufferedInputStream(item.getInputStream())

//文件存储在工程的upload目录下,这个目录也得存在 BufferedOutputStream out = new BufferedOutputStream( new FileOutputStream(new File("../webapps/fileupload/upload/带衫" + fileName)))

Streams.copy(in, out, true)

} } } else { System.out.println("enctype error!")

} } }

因为使用tomcat做得服务器,所以里蠢烂腔面的路径都是以tomcat为基础来写得,具体情况需要修改。

一直使用django的manage.py 的runserver 命令来运行竖链宽django应用,但这只是我们的开发环境,当项目真唤肆正部署上线的时候这做就不可行了,必须将我们的项目部署到特定的web服务器上。余亮


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/tougao/12323335.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-24
下一篇 2023-05-24

发表评论

登录后才能评论

评论列表(0条)

保存