rest - Spring MVC 4.0 RESTFul Web Services -


i trying build hello world restful web service of spring mvc 4.0 framework. created dynamic web application added web.xml , rest-servlet.xml , mycontroller.java file in package mythird.attempt.sample.controller.

web.xml

<?xml version="1.0" encoding="utf-8"?> <web-app>      <display-name>my sample rest</display-name>     <welcome-file-list>         <welcome-file>index.jsp</welcome-file>     </welcome-file-list>      <servlet>         <servlet-name>rest</servlet-name>         <servlet-class>org.springframework.web.servlet.dispatcherservlet</servlet-class>         <load-on-startup>1</load-on-startup>     </servlet>      <servlet-mapping>         <servlet-name>rest</servlet-name>         <url-pattern>/*</url-pattern>     </servlet-mapping> </web-app> 

rest-servlet.xml

    <?xml version="1.0" encoding="utf-8"?> <beans xmlns="http://www.springframework.org/schema/beans"  xmlns:context="http://www.springframework.org/schema/context"  xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance"  xmlns:p="http://www.springframework.org/schema/p"  xsi:schemalocation="         http://www.springframework.org/schema/beans              http://www.springframework.org/schema/beans/spring-beans-4.0.xsd         http://www.springframework.org/schema/context         http://www.springframework.org/schema/context/spring-context-4.0.xsd         http://www.springframework.org/schema/mvc         http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd">  <context:component-scan base-package="mythird.attempt.sample.controller" />  <mvc:annotation-driven />    </beans> 

mycontroller.java

package mythird.attempt.sample.controller; import org.springframework.web.bind.annotation.pathvariable; import org.springframework.web.bind.annotation.requestmapping; import org.springframework.web.bind.annotation.requestmethod; import org.springframework.web.bind.annotation.responsebody; import org.springframework.web.bind.annotation.restcontroller; @restcontroller @requestmapping("/myfirst") public class mycontroller {     @requestmapping(value = "/{name}", method = requestmethod.get)      public string getgreeting(@pathvariable string name) {       string result="hello "+name;         return result;      }      @requestmapping(value="/qq", method = requestmethod.get)     @responsebody      public string getgreeting1() {       string result="hello world";         return result;      } } 

i tried deploying on both apache tomcat , glassfish. when hit url "localhost:8080//.../myfirst/asdf in browser glassfish gave warnings "no mapping found http request uri [/myfirst/asdf] in dispatcherservlet name.."

and gave dialog details , ok , on clicking details

it gives

system.deployment.application.invaliddeploymentexception (manifestparse) - exception reading manifest localhost:8080/testapache1/myfirst/kk: manifest may not valid or file not opened. - source: system.deployment - stack trace: @ system.deployment.application.manifestreader.fromdocument(string localpath, manifesttype manifesttype, uri sourceuri)

please me out here!!. in advance!!

i think url should "localhost:8080/{warname}/rest/myfirst/asdf

the web.xml says servlet kick in url's have "rest" path in it, not think using in sample attempts


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -