2016-07-04 93 views
0

我使用Java編寫App Engine應用程序。我想讓我的URL看起來好得多,因爲ASP.NET上的URL路由。這是我的web.xml如何使用Java JSP從routing-url Google App Engine獲取參數

<servlet> 
    <servlet-name>test</servlet-name> 
    <jsp-file>/test.jsp</jsp-file> 
</servlet> 

<servlet-mapping> 
    <servlet-name>test</servlet-name> 
    <url-pattern>/test/*</url-pattern> 
</servlet-mapping> 

當我鍵入http://localhost:8888/test/123它爲我工作,我用request.getPathInfo()獲得的*

值寄回/123,所以我不得不刪除被/它替換爲空焦炭。如果輸入http://localhost:8888/test/abc/123則返回/ abc/123,但是我想要的值僅爲abc

有沒有更好的方法或模式或庫來解決此問題?

+2

使用spring來構建服務 - https://spring.io/guides/gs/rest-service – Mithun

+0

我在這裏閱讀了關於spring的內容,並且我認爲不要使用spring。 https://cloud.google.com/appengine/articles/spring_optimization –

回答

0

它返回/ 123,所以我必須刪除/通過將其替換爲空字符。如果我輸入http://localhost:8888/test/abc/123它會返回/ abc/123,但是我想要的值僅爲abc

您可以將字符串拆分爲數組。

+0

是的,這就是我現在正在做的。 –