tomcat - Spring servlet mapping not working -


when try load http://localhost:8080/people receive 404 page not found error.

this servlet mapping iwthin web.xml :

<servlet>     <servlet-name>spring</servlet-name>     <servlet-class>         org.springframework.web.servlet.dispatcherservlet     </servlet-class>     <init-param>         <param-name>contextconfiglocation</param-name>         <param-value>classpath:applicationcontext.xml</param-value>     </init-param>     <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping>     <servlet-name>spring</servlet-name>     <url-pattern>/people/*</url-pattern> </servlet-mapping> 

here how understand works :

a url request http://localhost:8080/people intercepted servlet "spring" , invoke class org.springframework.web.servlet.dispatcherservlet correct ?

do need additional configuration in order class loaded correctly ?

update :

here controller :

@controller public class personcontroller {      @autowired     private personservice personservice;      @requestmapping("/")     public string listpeople(map<string, object> map) {          map.put("person", new person());         map.put("peoplelist", personservice.listpeople());          return "people";     }      @requestmapping(value = "/add", method = requestmethod.post)     public string addperson(@modelattribute("person") person person, bindingresult result) {          personservice.addperson(person);          return "redirect:/people/";     }      @requestmapping("/delete/{personid}")     public string deleteperson(@pathvariable("personid") integer personid) {          personservice.removeperson(personid);          return "redirect:/people/";     } } 

do have controller backing support get response?

something this

@controller @requestmapping(value = "/people") public class logincontroller {      @requestmapping(value = "/i_am_here", method = requestmethod.get)     public string firstform() {         return "show_me_the_jsp_page";     } } 

based on above example, make url request -> /people/i_am_here

method invoked , response sent in jsp.

checkout example under github

https://github.com/hth/statusinvoke/blob/master/src/com/example/usercontroller.java


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -