java - How to make my URL to only be "localhost:8080/*"? -


i'm starting out giving spring mvc have no idea i'm doing. therefore, started following series of tutorials on youtube. i've followed them step step differing in i'm using sts instead of og eclipse set project tut can't see why matter.

towards end make index.jsp page, restart server, , navigate localhost:8080/index.html , "problem" begins. have use localhost:8080/test/index.html in order avoid 404 error.

i think answer obvious i'm not clear why mine's different tut's though followed it, names aside, exactly.

how make url localhost:8080/*? don't want /test/ included.

beginning of pom.xml:

  <modelversion>4.0.0</modelversion>   <groupid>my.name.spring.test</groupid>   <artifactid>blog-aggregator</artifactid>   <version>0.0.1-snapshot</version>   <packaging>war</packaging> 

web.xml:

<?xml version="1.0" encoding="utf-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemalocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0">   <display-name>blog-aggregator</display-name>   <welcome-file-list>     <welcome-file>index.html</welcome-file>     <welcome-file>index.htm</welcome-file>     <welcome-file>index.jsp</welcome-file>     <welcome-file>default.html</welcome-file>     <welcome-file>default.htm</welcome-file>     <welcome-file>default.jsp</welcome-file>   </welcome-file-list>      <servlet>         <servlet-name>dispatcher</servlet-name>         <servlet-class>org.springframework.web.servlet.dispatcherservlet</servlet-class>         <load-on-startup>1</load-on-startup>     </servlet>      <servlet-mapping>         <servlet-name>dispatcher</servlet-name>         <url-pattern>*.html</url-pattern>         <url-pattern>*.htm</url-pattern>         <url-pattern>*.json</url-pattern>         <url-pattern>*.xml</url-pattern>          </servlet-mapping> </web-app> 

indexcontroller.java:

@controller public class indexcontroller {      @requestmapping("/index")     public string index() {         return "/web-inf/jsp/index.jsp";     } } 

dispatch-servlet.xml:

<?xml version="1.0" encoding="utf-8"?> <beans xmlns="http://www.springframework.org/schema/beans"     xmlns:xsi="http://www.w3.org/2001/xmlschema-instance"     xmlns:context="http://www.springframework.org/schema/context"     xsi:schemalocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd         http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.1.xsd">      <context:component-scan base-package="wilk.robert.spring.test.controller" /> </beans> 

i'm guessing has base package seems limit me on package can be; doesn't sound right (remember i'm ignorant!).

if there's important code missing promptly add it.

rename war root.war , deploy it

if webapp called root.war or directory called root/ jetty deploys @ / context.

jetty link

add next line pom.xml rename war file:

<build>   <finalname>root</finalname> </build> 

if using jetty plugin modify plugin configuration following code:

 <plugin>                 <groupid>org.mortbay.jetty</groupid>                 <artifactid>maven-jetty-plugin</artifactid>                 <version>6.1.22</version>                 <configuration>                     <contextpath>/</contextpath>                                      </configuration>                 ...             </plugin> 

Comments

Popular posts from this blog

java - HTTP Status 500 - An exception occurred processing JSP page /second.jsp at line 15 -

php - Using str_replace to translate a MySQL Table in html -

SQL Server - MyCTE query based on 24 hour period (next day) -