Frage

I know this is long but please bear with me......

I am using xubuntu. I have a spring mvc project named Fitness Tracker.It has a standard directory structure. I also have apache2 on my machine which i installed using commandline. I have created a file named default1 inside sites-available directory which contains following code:

<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>

My httpd.conf contains following code

ServerName localhost     
DirectoryIndex hello.jsp

Additioanlly ,My spring controller name is Hello Controller and it contains following code:-

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";
}
}

Now when i type east.example.org in address bar of my browser i get hello.jsp page which contains code of hello.jsp page(i.e.spring mvc code along with html code).

My requirement is when i start my apache server and type east.example.org in address bar of my browser i want to display greeting.html page. How can this be done?? Note that there exists no page of name greeting.html. But Spring enables us to route the request to hello.jsp page when greeting.html page is requested.

P.S. I have used spring tags inside my jsp page.How can i get access to greeting.html page??

War es hilfreich?

Lösung

  • Apache - Is a web server.

  • Tomcat - Is an Application server(Servlet container).

Apache cannot host servlets, It can be done only with Servlet Containers like Tomcat, Jboss etc.

Refer Difference between the Apache HTTP Server and Apache Tomcat?

Andere Tipps

I have used tomcat for java apps.It is kind of complicated using spring mvc with apache.

You configure Tomcat to run your Spring application (by configuring web.xml), and then you configure Tomcat to connect with Apache using mod-jk. You have to set up your apache configurations files to know about mod-jk, and you configure mod-jk.conf (See: http://tomcat.apache.org/connectors-doc/webserver_howto/apache.html)

Hope this helps

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top