小编Ann*_*mer的帖子

如何在Apache服务器中托管spring应用程序?

我知道这很长但请耐心等待......

我正在使用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>
Run Code Online (Sandbox Code Playgroud)

我的httpd.conf包含以下代码

ServerName localhost     
DirectoryIndex hello.jsp
Run Code Online (Sandbox Code Playgroud)

Additioanlly,我的Spring控制器名称是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";
}
}
Run Code Online (Sandbox Code Playgroud)

现在当我在浏览器的地址栏中键入east.example.org时,我会得到hello.jsp页面,其中包含hello.jsp页面的代码(iespring mvc代码和html代码).

我的要求是当我启动我的apache服务器并在浏览器的地址栏中键入east.example.org时,我想显示greeting.html页面.如何才能做到这一点??请注意,没有名称greeting.html的页面.但是当我们请求greeting.html页面时,Spring允许我们将请求路由到hello.jsp页面.

PS我在jsp页面中使用了spring标签.如何才能访问greeting.html页面?

apache jsp spring-mvc xubuntu

3
推荐指数
1
解决办法
3878
查看次数

如何手动(而不是通过控制器向导)向rails应用程序中的ruby中的控制器添加视图?

我正在使用Ruby mine在rails应用程序上构建ruby.一切都很好.我创建了新项目,然后按Ctrl + Alt + G. 从发电机选项我选择控制器.然后我得到一个窗口,我必须在其中命名控制器和操作.当我选择不同的动作时,会在以我的动作命名的控制器中创建相应的功能.如果我按下该功能名称左​​侧的图标,我会获得为具有extension.html.erb的特定功能打开的视图文件.这很好.但是,如果我忘记在控制器对话框中添加一个或多个动作,该怎么办?然后据说我必须添加一个名称是我想要的视图的函数.即

def functionname

end
Run Code Online (Sandbox Code Playgroud)

现在当我点击这个功能名的左侧时.我可以选择创建扩展名为.html.erb的文件.所有这一切都很好.但是,当我构建此应用程序并尝试访问此新创建的视图时,我收到以下错误

    Routing Error
No route matches [GET] "/say_hello/sona"
Try running rake routes for more information on available routes.
Run Code Online (Sandbox Code Playgroud)

如何向控制器添加视图,除了使用该控制器向导?之后我不能添加视图吗?`

ruby-on-rails rubymine rails-routing

0
推荐指数
1
解决办法
4481
查看次数