simple issue on url mapping with spring -


i develop spring 4.1. try map urls controllers

here extract of web.xml file

<!-- spring mvc -->     <servlet>     <servlet-name>mvc-dispatcher</servlet-name>     <servlet-class>org.springframework.web.servlet.dispatcherservlet</servlet-class>     <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping>     <servlet-name>mvc-dispatcher</servlet-name>     <url-pattern>/*</url-pattern> </servlet-mapping> 

here extract of spring xml file

        <bean id="viewresolver"       class="org.springframework.web.servlet.view.urlbasedviewresolver">       <property name="viewclass"             value="org.springframework.web.servlet.view.jstlview" />       <property name="prefix">         <value>/web-inf/pages/</value>       </property>       <property name="suffix">         <value>.jsp</value>       </property>     </bean>  <context:component-scan base-package="orm,orm.impl,web.controller.impl,web.view" /> 

here extract of controller file

    package web.controller.impl;  import java.util.arraylist; import java.util.hashmap; import java.util.list; import java.util.map;  import org.apache.logging.log4j.logmanager; import org.apache.logging.log4j.logger; import org.springframework.beans.factory.annotation.autowired; import org.springframework.beans.factory.annotation.qualifier; import org.springframework.stereotype.controller; import org.springframework.ui.modelmap; import org.springframework.web.bind.annotation.requestmapping; import org.springframework.web.bind.annotation.requestmethod; import org.springframework.web.servlet.modelandview;  import service.commonmanagementservice; import web.view.questionitem; import domain.question;  @controller public class combocontroller  {        private static final logger logger = logmanager.getlogger();      @autowired     @qualifier("commonmanagementservice")     private commonmanagementservice commonmanagementservice;      public commonmanagementservice getcommonmanagementservice() {         return this.commonmanagementservice;     }      @requestmapping(value = "/unsecure/getquestion", method = requestmethod.get)     public modelandview getquestion(modelmap model) {         logger.info("debut methode getquestion");         final list<questionitem> results = new arraylist<questionitem>();         final list<question> questions = this.commonmanagementservice.getquestions();         (final question question : questions) {             results.add(new questionitem(question.getquestion(), question.getid().tostring()));         }         final map<string, object> modeltopass = new hashmap<string, object>();         model.put("items", results);         logger.info("fin methode getquestion");         return new modelandview("jsonresultview", model);      }      public void setcommonmanagementservice(             commonmanagementservice commonmanagementservice) {         this.commonmanagementservice = commonmanagementservice;     } } 

the name of application tennisarc1600 , when try send url http://localhost:8080/tennisarc1600/unsecure/getquestion or http://localhost:8080/unsecure/getquestion error 404 ressource not available

thank in advance suggestions

use in web.xml

<url-pattern>/</url-pattern> 

and declare

<mvc:annotation-driven/> 

or alternatively

<bean class="org.springframework.web.servlet.mvc.annotation.defaultannotationhandlermapping">     <property name="order" value="1" /> </bean> 

in spring web configuration


Comments

Popular posts from this blog

c# - Better 64-bit byte array hash -

webrtc - Which ICE candidate am I using and why? -

php - Zend Framework / Skeleton-Application / Composer install issue -