tomcat上傳
㈠ dist上傳去tomcat怎麼啟動
dist上傳去tomcat按以下步驟啟動:
1、在開始菜單中選擇所有程序,在所有程序中有一個ApacheTomcat的文件夾,單擊展開。
2、選擇這個文件夾中的ConfigureTomcat程序、單擊啟動。
3、在主界面中就可以看到一個Start的開始按鈕了,單擊等待一會就可以啟動tomcat了。
㈡ 怎麼向tomcat伺服器上傳文件
1.將tomcat環境搭配好
path中加入:
%CATALINA_HOME%\lib;%CATALINA_HOME%\bin;
2.修改tomcat中config/server.xml
<Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true">
<!-- SingleSignOn valve, share authentication between web applications
Documentation at: /docs/config/valve.html -->
<!--
<Valve className="org.apache.catalina.authenticator.SingleSignOn" />
-->
<!-- Access log processes all example.
Documentation at: /docs/config/valve.html
Note: The pattern used is equivalent to using pattern="common" -->
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="localhost_access_log." suffix=".txt"
pattern="%h %l %u %t "%r" %s %b" resolveHosts="false"/>
<Context docBase="D:\workspace\picture\target\mvc-basic.war" path="/picture"/>
</Host>
添加紅色部分
docBase中要為項目打包成的war文件。
path隨意
啟動tomcat bin\startup.bat,如果這時tomcat一閃而過,表示啟動異常,很可能是配置或者server.xml出問題了。
注意:有時即使更改了war文件裡面的文件,程序仍然沒有任何變化,這個時候要把apache-tomcat-7.0.11\webapps下的項目文件給刪除,再重新啟動tomcat。
由於我是用eclipse開發的,下面那段紅色線表示我發布的位置,wtpwebapps下,我試過,只有把圖片放在D:\workspace
\.metadata\.plugins\org.eclipse.wst.server.core\tmp4\wtpwebapps\ROOT裡面項目
才能讀取到圖片。而如果將項目打包成war後,更改<Context docBase="D:\workspace\picture\target\mvc-basic.war" path="/picture"/>更tomcat的根目錄是apache-tomcat-7.0.11\webapps,只需要在這個下面建立images目錄,把圖片往裡面存就行了。
3.代碼
[java] view plain
private static final String PICTURE_WEB_INF = "/picture/WEB-INF";
private static final String ROOT_IMAGES_PICTURE = "/ROOT/images/picture";
private static final String IMAGES_PICTURE = "/images/picture";
@RequestMapping(value = "/add",method = RequestMethod.POST)
public String save(Picture picture, HttpServletRequest request) {
this.FileAndSaveFile(request, picture);
this.pictureService.save(picture);
return "redirect:/index";
}
private void FileAndSaveFile(HttpServletRequest request, Picture material) {
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
for (Map.Entry<String, MultipartFile> entity : multipartRequest.getFileMap().entrySet()) {
MultipartFile mf = entity.getValue();
String uuid = UUID.randomUUID().toString();
String classPath = this.getClass().getClassLoader().getResource("/").getPath();
try {
classPath =URLDecoder.decode(classPath, "gb2312");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
classPath = classPath.split(PICTURE_WEB_INF)[0];
File pictureFile = new File(classPath+ROOT_IMAGES_PICTURE);
if(!pictureFile.exists()){
pictureFile.mkdirs();
}
String path = pictureFile.getPath();
String ext = null;
try {
if (null == mf || mf.isEmpty() || null == mf.getInputStream() || mf.getSize() > 40000000) {
return;
}
ext = Files.getFileExtension(mf.getOriginalFilename());
if(classPath.indexOf("wtpwebapps")!=-1){
path = classPath+ROOT_IMAGES_PICTURE;
}else{
path = classPath+IMAGES_PICTURE;
}
File f = new File(path +"/" + uuid + "." + ext);
Files.createParentDirs(f);
FileCopyUtils.(mf.getBytes(), f);
material.setFilePath(IMAGES_PICTURE + "/" + uuid + "." + ext);
material.setFileName(mf.getOriginalFilename());
} catch (IOException e) {
e.printStackTrace();
}
}
}
因為使用eclipse開發的,所以會是indexof(wtpwebapps),其他的開發工具要看情況。
jsp:
另外img src好像不支持用絕對路徑,顯示不出來,我也不知道為什麼,網路了很多都沒說,但是絕對路徑應該是不可行的,因為有時需要移植什麼的容易出現問題。
[html] view plain
<head>
<title>圖片列表</title>
<script language="javascript" src="./resources/js/jquery-1.8.3.js"> </script>
<script language="javascript" src="./resources/js/jquery.validate.min.js"> </script>
<script language="javascript" src="./resources/js/picture/add.js"> </script>
</head>
<body>
<form action = "<c:url value = "/picture/add"></c:url>" method = "post" id="add_form" enctype="multipart/form-data">
<table class="tab01">
<tr>
<td class="name">名稱:</td>
<td><input id = "name" type="text" class="text_input" name="title" placeholder="標題"/></td>
<td><label for="title" class="error" generated="true" style="color:red;font-size:12px;"></label></td>
</tr>
<tr>
<td class="name">上傳圖片:</td>
<td><input type="file" class="text_input" name="file" id="file" placeholder="上傳圖片"/></td>
<td><label for="file" class="error" generated="true" style="color:red;font-size:12px;"></label></td>
</tr>
<tr>
<td> </td>
<td colspan="2">
<input type="submit" class="button" id="submitButton" value="提交" name="reset" />
<input type="reset" class="button" value="重置" name="reset" />
</td>
</tr>
</table>
</form>
<br/><br/><br/>
<c:forEach items = "${pictureList }" var = "picture">
<p>${picture.title }</p>
<div><img src="${picture.filePath }" width = "500" height = "500" BORDER="0" ALT="無圖片"/>
</div>
</c:forEach>
</body>
[javascript] view plain
$(function(){
jQuery.validator.messages.required = "<span class='error' generated='true' style='color: red; font-size: 12px;'>*請填寫此內容</span>";
jQuery.validator.messages.maxlength = "<span class='error' generated='true' style='color: red; font-size: 12px;'>*已達到最大字元數 </span>";
jQuery.validator.messages.accept = "<span class='error' generated='true' style='color: red; font-size: 12px;'>*請輸入擁有合法後綴名的字元串 </span>";
$("#add_form").validate({
rules : {
title : {required : true, maxlength :200 },
file : {required : true}
}
});
$("input[type='file']").change(function(){
alert(this.files[0].size);
if(this.files[0].size>300*1024){
alert("圖片太大!!圖片不大於300KB");
$("#submitButton").attr("disabled","disabled");
}else{
$("#submitButton").removeAttr("disabled");
}
});
$("#add_form").submit(function() {
var filepath=$("input[name='file']").val();
var extStart=filepath.lastIndexOf(".");
var ext=filepath.substring(extStart,filepath.length).toUpperCase();
if(ext!=".BMP"&&ext!=".PNG"&&ext!=".GIF"&&ext!=".JPG"&&ext!=".JPEG"){
alert("圖片限於bmp,png,gif,jpeg,jpg格式");
return false;
}
return true;
});
});
㈢ tomcat怎麼上傳war包
首先,在項目上右擊,選擇export,之後選擇other,在找到war file,點擊下一步; 然後,選擇保存路徑為tomcat下的webappen路徑,並填寫上文件名稱,之後finsh; 最後,找到tomcat下的bin路徑,點擊startup.bat運行即可,
㈣ tomcat中如何設置文件上傳大小的控制,例如:超過Tomcat限定的50M , 而本人需要上傳90M的WAR文件。
1、打開tomcat的默認配置文件(tomcat程序安裝目錄下的conf文件夾中的server.xml文件)。
2、找到裡面的<Connector>標簽,在該標簽中添加"maxPostSize"屬性,將該屬性值設置成你想要的最大值,單位是位元組,或者把這個值設置為 0(maxPostSize="0"),tomcat將不再檢查文件的大小。即可解決上述問題。
㈤ Tomcat中上傳應用程序時,應用程序是什麼類型的文件
WebArchive。
Tomcat中上傳應用程序時,應用程序是一個(WebArchive)類型的文件。WAR是Sun提出的一種Web應用程序格式,與JAR類似,也是許多文件的一個壓縮包。
應用程序是指為了完成某項或某幾項特定任務而被開發運行於操作系統之上的計算機程序。應用程序與應用軟體的概念不同,但常常因為概念相似而被混淆。軟體指程序與其相關文檔或其他從屬物的集合。一般我們視程序為軟體的一個組成部分。
㈥ 怎樣通過tomcat上傳文件
你是想發布工程,還是想發布或新增修改個頁面,例如jsp。如果是這樣的話,看看你是什麼伺服器,如果windows,直接替換就可以。如果是unix或linux等系統,利用ftp,或 scp命令行 替換即可。然後重新啟動 tomcat。就OK 了。
㈦ tomcat上傳文件問題
第一步:需要先創建一個server,可以通過windows中的show view,之後找到server,
第二步:在server窗口中右擊,選擇」new-server「,之後創建好tomcat server。
第三步:雙擊創建的server,進入server設置界面,設置Server Location,選擇編譯路徑是」Use Tomcat「即可切換到Tomcat的路徑,保存。
第四步:之後將server項目添加到此server下,這樣就完成了部署到Tomcat下。
㈧ SpringBoot tomcat 上傳文件大小受限制
applicaton.properties配置:
spring.servlet.multipart.max-file-size=200MB
spring.servlet.multipart.max-request-size=200MB
或
application.yml配置:
# Spring配置
spring:
# 文件上傳
servlet:
multipart:
# 單個文件大小
max-file-size: 20000MB
# 設置總上傳的文件大小
max-request-size: 50000MB
並且添加如下配置文件
import javax.servlet.MultipartConfigElement;
import org.springframework.boot.web.servlet.MultipartConfigFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.util.unit.DataSize;
@Configuration
public class UploadConfig {
@Bean
public MultipartConfigElement multipartConfigElement() {
MultipartConfigFactory factory = new MultipartConfigFactory();
//文件最大20000M
factory.setMaxFileSize(DataSize.ofMegabytes(20000));
// factory.setMaxFileSize(DataSize.parse("100MB"));
// 設置總上傳數據總大小
factory.setMaxRequestSize(DataSize.parse("50000MB"));
return factory.createMultipartConfig();
}
}
㈨ tomcat上傳比遠程桌面復制慢
因為文件容量過大。
tomcat運行正常,上傳數據很緩慢,或者數據丟失。檢查網路正常,檢查資料庫正常,也不卡頓,就是上傳數據到資料庫的時候很卡頓。如果是上述情況,既不是網路也不是資料庫出現問題,建議壓縮文件,或者選擇遠程桌面復制上傳。