[英]How to get parameter from routing-url Google App Engine using Java JSP
I write an App Engine Application using Java. 我使用Java编写了App Engine应用程序。 I want to make my url look much better as URL Routing on ASP.NET.
我想使我的网址看起来更好,就像ASP.NET上的网址路由一样。 this is my Web.xml
这是我的Web.xml
<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>
When I type http://localhost:8888/test/123 it work for me, And I use request.getPathInfo()
to get value of * 当我输入http:// localhost:8888 / test / 123时,它对我有用,并且我使用
request.getPathInfo()
获得*的值
it return /123
, So I have to remove /
by replace it to blank char. 它返回
/123
,所以我必须删除/
通过将其替换为空白字符。 If I type http://localhost:8888/test/abc/123 it return /abc/123, but the value I want is only abc
如果我输入http:// localhost:8888 / test / abc / 123,则返回/ abc / 123,但我想要的值仅为
abc
Are there a better ways or pattern or library to solve this problem? 是否有更好的方法或模式或库来解决此问题?
it return /123, So I have to remove / by replace it to blank char.
它返回/ 123,所以我必须删除/,将其替换为空白字符。 If I type http://localhost:8888/test/abc/123 it return /abc/123, but the value I want is only abc
如果我输入http:// localhost:8888 / test / abc / 123,则返回/ abc / 123,但我想要的值仅为abc
You could split the String to an array. 您可以将String拆分为一个数组。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.