1

http:// localhost:8080 / HelloWorldSpring3 / forms/helloworldで正常に動作する次のコードがあります

しかし、私はURLにこのようなものを持たせたい

http:// localhost:8080 / HelloWorldSpring3 / forms / helloworld / locname_here / locid_here

この@RequestMapping( "/ helloworld / **")を追加すると機能することがわかりましたが、アクセスしようとすると

http:// localhost:8080 / HelloWorldSpring3 / forms / helloworld / locname_here / locid_here

見つかりません。

次のようなWeb.xmlエントリ

<servlet-mapping>
      <servlet-name>dispatcher</servlet-name>
      <url-pattern>/forms/*</url-pattern>
    </servlet-mapping>

Beanエントリのマッピング

@RequestMapping("/helloworld/**")
       public ModelAndView helloWord(){
              String message = "Hello World, Spring 3.0!";
              return new ModelAndView("helloworld", "message",message);
       }
4

1 に答える 1

0
@Controller
@RequestMapping(value="/helloworld")
public class HelloWorldController{

    @RequestMapping(value = "/{locname_here}/{locid_here}")
    public ModelAndView helloWorld(@PathVariable String locname_here, @PathVariable long locid_here) {
        //Logic
    }

}

上記のコードは、要件に応じて機能します。

于 2011-02-21T07:23:12.800 に答える