I have a simple spring 3 mvc application, that just ouputs index.aspx when someone browses to http://localhost:8080/
When I do RunAs and run on server option (which is hooked into tomcat 6), it opens up the browser to http://localhost:8080/springmvc2/ (where springmvc2 is the applications name).
I have build this same simple test app using netbeans at it works fine using the url http://localhost:8080/
My web.xml:
<!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd" >
<web-app>
<display-name>Springmvc2</display-name>
<description>Springmvc2 web application</description>
<servlet>
<servlet-name>Springmvc2</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<!-- Maps all /app requests to the DispatcherServlet for handling -->
<servlet-mapping>
<servlet-name>Springmvc2</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
</web-app>
And my HomeController is:
package com.springmvc2.web;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
@Controller
public class HomeController {
@RequestMapping("/")
public String Index(){
return "index";
}
@RequestMapping("/test")
public String Index2(){
return "index";
}
}
You can view my pom.xml file here: http://stackoverflow.com/questions/2234059/using-eclipse-with-maven-plugin-how-should-i-setup-my-build-so-it-deploys-to-tom
This is the target folder that is generated also:
/target
/target/springmvc2/meta-inf
/target/springmvc2/web-inf
/target/springmvc2/test.html
/target/war/springmvc2.war
/target/pom.xml
I created test.html just to see if at least this renders, but http://localhost:8080
/test.html doesn't work, and http://localhost:8080/springvc2/test.html
doesn't work either.
I am getting a 404 error so I guess it is not deploying to tomcat properly, especially since the test.html file doesn't even render.
But maybe the test.html isn't rendering because I have this in my springmvc2-servlet.xml
:
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver" p:prefix="/WEB-INF/jsp/"
p:suffix=".jsp" p:order="2"/>
I have to admit, Java development is riddled with configuration issues, especially for newbies!!
Update
compiling and doing a runas serving, opens the browser and I get this message from tomcat:
WARNING: No mapping found for HTTP request with URI [/springmvc2/] in DispatcherServlet with name 'springmvc2'