Java 동적 웹 프로젝트에서 Spring을 사용했지만 Windows에서 제대로 작동하지만 컨트롤러를 작동하지 않으면 Ubuntu VM에 배포 한 후에도 만들었습니다. war 파일을 Eclipse Windows에 설치하고 Tomcat 관리자를 통해 배포했지만 작동하지 않았습니다.Windows에서 Linux로 응용 프로그램을 배포 한 후 컨트롤러가 작동하지 않습니다.
그런 다음 webapps 폴더에 동일한 구조의 src 코드를 복사했지만 .jsp 페이지 만 표시하고 페이지를 @requestMapping에 매핑하지 않고 컨트롤러 클래스를 호출합니다. 설정/리눅스에서 작동하도록 구성? 응용 프로그램을 연 후
이 index.jsp가이 내용을 보여줍니다 만, 제출을 클릭 한 후이 <form class="formcolor" action="tiers" method="GET">
통해 AppDynamicsMain.java 컨트롤러를 호출하도록되어 있지만 대신 표시 할 계층 페이지를 찾고 및 HTTP 상태 404를 발생 - 찾을 수 없습니다
나는 $ CATALINA_HOME/webapps에/appd-CP /의 WebContent에서 필요한 모든 jar 파일// lib에 WEB-INF/나는 $ CATALINA_HOME/lib 디렉토리로 이동해야하나요 한 /?
귀하의 도움에 크게 감사드립니다.
PS : 내 VM, 아니 GUI가 없습니다 그것은 내가로 전화를 걸 내 프로젝트의 루트에 추가 index.jsp를했습니다
단자를 통해 (는 IP 사용 mobaXterm에 SSH)에만 액세스 할 수 프로젝트 JSP 폴더에 index.jsp를 :/index.jsp를 $ CATALINA_HOME/webapps에/appd-CP :
<html>
<head>
<META http-equiv="refresh" content="0;URL=welcome.jsp">
</head>
<body>
</body>
</html>
:의 WebContent/WEB-INF/JSP/index.jsp에서의
<html>
<head>
<META http-equiv="refresh" content="0;URL=WebContent/WEB-INF/jsp/index.jsp">
</head>
<body>
</body>
</html>
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 디렉토리 아래의 컨텐츠는 외부 세계로부터 직접 액세스 할 수 없습니다. 이것은 서블릿 컨테이너에 의해 보호됩니다. 이 디렉토리가 수동으로 만든 디렉토리라면 파일 사용 권한을 확인하는 것이 좋습니다. –