我知道這很長,但請忍受我......Spring應用程序如何在Apache服務器上託管?
我使用的是xubuntu。我有一個名爲Fitness Tracker的彈簧mvc項目。它有一個標準的目錄結構。我也有我的機器上使用命令行安裝的apache2。我創建了一個名爲缺省1內部網站,提供目錄文件,其中包含下面的代碼:
<VirtualHost *:80>
ServerName east.example.org
DocumentRoot /var/www/hello/FitnessTracker/src/main/webapp/WEB-INF/jsp
<Directory /var/www/hello/FitnessTracker/src/main/webapp/WEB-INF/jsp>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
</VirtualHost>
我的httpd.conf中包含下面的代碼
ServerName localhost
DirectoryIndex hello.jsp
Additioanlly,我的春天控制器名稱爲你好控制器和它包含下面的代碼: -
package com.pluralsight.controller;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
public class HelloController {
@RequestMapping(value="/greeting")
public String sayHello(Model model)
{
model.addAttribute("greeting", "Hello World");
return "hello";
}
}
現在,當我鍵入east.example.org在我的瀏覽器的地址欄中,我得到了hello.jsp頁面,其中包含hello.jsp頁面的代碼(即mspc代碼和html代碼)。
我的要求是,當我開始我的Apache服務器,並在瀏覽器的地址欄中鍵入east.example.org我想顯示greeting.html頁。如何才能做到這一點??請注意,不存在名稱greeting.html的頁面。但是,當請求greeting.html頁面時,Spring使我們能夠將請求路由到hello.jsp頁面。
P.S.我在我的jsp頁面中使用了spring標籤。如何訪問greeting.html頁面?
爲什麼不tomcat的? –
@ Santino'Sonny'Corleone我不知道........這是我的客戶要求 –