私はJavaの動的WebプロジェクトでSpringを使用しましたが、Windows上でうまく動作しますが、Ubuntu VMにコントローラを配備しても動作しません。 WARファイルをEclipse Windowsにインストールし、Tomcatマネージャを使用して展開しましたが動作しませんでした。WindowsからLinuxにアプリケーションを配備した後にコントローラが動作しない
私は単純にwebappsフォルダと同じ構造のsrcコードをコピーしましたが、.jspページのみを表示し、ページを@requestMappingにマップせず、コントローラクラスを呼び出します。それを動作させるには、linuxのセットアップ/設定?
アプリケーションを開いた後、index.jspがコンテンツを表示しますが、サブミットをクリックすると、<form class="formcolor" action="tiers" method="GET">
経由でAppDynamicsMain.javaコントローラが呼び出されますが、代わりに階層のページが表示され、HTTPステータス404が見つかりません -
私は$ CATALINA_HOME/webappsに/ APPD-CP/WebContentを/ WEB-INF// libの下にあるすべての必要なjarファイルを持って、私は/彼らに$ CATALINA_HOME/libに移動する必要がありますか?
お手数をおかけしますようお願い申し上げます。
PS:私のVMは何のGUIを持っていない、それは(mobaXtermを使用してIPへのSSH)端子を介してのみアクセス可能である
私はへの呼び出しを行うために私のプロジェクトのルートに余分のindex.jspをしなければなりませんでした$ CATALINA_HOME/webappsに/ APPD-CP/index.jspを::
<html>
<head>
<META http-equiv="refresh" content="0;URL=WebContent/WEB-INF/jsp/index.jsp">
</head>
<body>
</body>
</html>
のWebContent/WEB-INF /でindex.jspをJSP/index.jspを:
<html>
<head>
<META http-equiv="refresh" content="0;URL=welcome.jsp">
</head>
<body>
</body>
</html>
プロジェクトのJSPフォルダ内のindex.jsp
ここはVMのプロジェクト構造です:
appd-cp
|->index.jsp
|->src
| -->com.sh
| --->AppDynamicsMain.java
|->WebContent
| -->WEB-INF
| --->jsp
| ---->index.jsp
| ---->rawDataCPU.jsp
| ---->graphCPU.jsp
| --->CapacityPlanning-servlet.xml
| --->web.xml
のwelcome.jsp:
<html>
<head>
<title>my title</title>
</head>
<style type="text/css">
<%@include file="site.css" %>
</style>
<body>
<div id="flip-tabs" >
<ul id="flip-navigation" >
<li><a href="welcome.jsp" id="tab-0">Graph</a></li>  
<li class="selected"><a href="welcomeRawData.jsp" id="tab-1" >Raw Data</a></li>  
<li><a href="#" id="tab-2" >Subscribe</a></li>  
</ul>
</div>
<script>
function openNav() {
document.getElementById("mySidenav").style.width = "250px";
document.getElementById("main").style.marginLeft = "250px";
}
function closeNav() {
document.getElementById("mySidenav").style.width = "0";
document.getElementById("main").style.marginLeft = "0";
}
</script>
<BR><BR><div style="margin-left: 70px;"><p>select the application, parameter and the duration:</p></div>
<form class="formcolor" action="tiers" method="GET">
<label>Application: </label>
<select name="application">
<option name="application" value="ALEXA_SKILL">ALEXA_SKILL</option>
<option name="application" value="AMP">AMP</option>
</select>
<BR>
<BR>
<label>Parameter: </label>
<select name="param">
<option name="param" value="CPU">CPU usage</option>
</select>
<BR>
<BR>
<label>Duration: </label>
<select name="duration">
<option name="duration" value="5">5 min</option>
<option name="duration" value="15">15 min</option>
<option name="duration" value="30">30 min</option>
</select>
<BR>
<BR>
<BR>
<progress id="p1" max="100" value="0"><span>0</span>%</progress>
<input type="submit" value="Submit"></input>
<form>
</body>
</html>
AppDynamicsMain.java:
package com.sh;
import java.io.File;
import java.io.IOException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.log4j.Logger;
import org.apache.tomcat.util.http.fileupload.FileUtils;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import com.sh.PropertyFileReader;
@Controller
public class AppDynamicsMain {
protected static final String USERNAME = PropertyFileReader.getAppdUsername();
protected static final String PASSWORD = PropertyFileReader.getAppdPassword();
String DestPath = "/root/AppDynamics/";
public String fileName;
public String application;
static Log log = LogFactory.getLog(AppDynamicsMain.class.getName());
private Logger logger = Logger.getLogger(AppDynamicsMain.class);
static String downloadDestPath = "/root/AppDynamics/download/";
@RequestMapping(value = "tiers" , method = RequestMethod.GET)
public String getContent(@RequestParam(required = true) String application , @RequestParam(required = true) String param, @RequestParam(required = true) String duration, ModelMap model) throws IOException{
logger.info("################### going to call rawData"+ param+ " . . . ");
File checkFolder = new File(downloadDestPath);
if(checkFolder.isDirectory()){
if(checkFolder.list().length>0){
FileUtils.cleanDirectory(checkFolder);
}
}
model.addAttribute(application , application);
model.addAttribute(duration , duration);
return "forward:/rawData"+param;
}
@RequestMapping(value = "graphs" , method = RequestMethod.GET)
public String getGraphContent(@RequestParam(required = true) String application , @RequestParam(required = true) String param , ModelMap model){
logger.info("################### going to call get"+ param+ " . . . ");
model.addAttribute(application , application);
return "forward:/graph"+param;
}
}
のweb.xml:
<web-app id = "WebApp_ID" version = "2.4"
xmlns = "http://java.sun.com/xml/ns/j2ee"
xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation = "http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<display-name>Capacity Forecasting - Planning</display-name>
<servlet>
<servlet-name>CapacityPlanning</servlet-name>
<servlet-class>
org.springframework.web.servlet.DispatcherServlet
</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>CapacityPlanning</servlet-name>
<url-pattern>*</url-pattern>
</servlet-mapping>
<context-param>
<param-name>MONGODB_HOST</param-name>
<param-value>localhost</param-value>
</context-param>
<context-param>
<param-name>MONGODB_PORT</param-name>
<param-value>27017</param-value>
</context-param>
CapacityPlanning-servlet.xml:
<?xml version = "1.0" encoding = "UTF-8"?>
<beans xmlns = "http://www.springframework.org/schema/beans"
xmlns:context = "http://www.springframework.org/schema/context"
xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation = "http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/data/mongo
http://www.springframework.org/schema/data/mongo/spring-mongo-1.0.xsd">
<context:component-scan base-package = "com.sh" />
<bean id = "viewResolver"
class = "org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name = "prefix" value = "/WEB-INF/jsp/" />
<property name = "suffix" value = ".jsp" />
</bean>
<mvc:annotation-driven/>
</beans>
ログにエラーがありますか?私はあなたの申請書に問題があると思っています。 WEB-INFの下のファイルには、外部からアクセスできません。例えば'URL = WebContent/WEB-INF/jsp/index.jsp'は動作しません。あなたのアプリが正常に展開されたかどうかを確認できますか? .warをパッケージ化してApache/Tomcatにデプロイできるはずですか? –
@MinhKieu、私はwelcome.jspページにアクセスできます。URL = WebContent/WEB-INF/jsp/index.jspはプロジェクトのルートディレクトリのindex.jspから呼び出されていますが、URLへのアクセスには何も問題ありません。 – gr8code2be
ルートフォルダからファイルにアクセスできるかどうか確認できますか?私が言ったように、私の経験から、WEB-INFディレクトリの下のコンテンツは、外界から直接アクセスすることはできません。そのサーブレットコンテナによって保護されています。これが手動で作成したディレクトリの場合は、ファイルのアクセス許可を確認することをお勧めします。 –