我知道这很长,但请多多包涵……
我正在使用 xubuntu。我有一个名为Fitness Tracker的 spring mvc 项目。它有一个标准的目录结构。我的机器上也有apache2,我使用命令行安装了它。我在 sites-available 目录中创建了一个名为default1的文件,其中包含以下代码:
<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
另外,我的弹簧控制器名称是 Hello Controller,它包含以下代码:-
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 页面的代码(iespring mvc 代码和 html 代码)。
我的要求是当我启动我的 apache 服务器并在我的浏览器地址栏中键入east.example.org时,我想显示greeting.html页面。如何才能做到这一点??请注意,不存在名称 greeting.html 的页面。但是 Spring 使我们能够在请求 greeting.html 页面时将请求路由到 hello.jsp 页面。
PS我在我的jsp页面中使用了spring标签。如何访问greeting.html页面?