duanjian4698 2010-02-10 05:19
浏览 70
已采纳

获取完整的URL并使用JSP / ASP拆分为数组

In PHP/Apache I can get the full url and cut it up into parts like this

URL: example.com/friends/enemies-cats/

Then using PHP explode function I can split the URL by the "/" into an array.

Array[0] = 'friends';
Array[1] = 'enemies-cats';

I wonder, is it possible to do the same thing on a Java server. I am hoping the same thing could work on all servers e.g. tomcat, jboss, websphere etc. I would prefer not to use things like urlrewriter if I can avoid it.

Also is it possible to achieve the same thing in ASP?

Realistically, I would like to find the easiest way to convert the URL to an array in each of PHP, JSP, and ASP.

If it is possible, any idea where to start? Any limitations? Any security issues, etc.?

  • 写回答

1条回答 默认 最新

  • doutian3010 2010-02-10 05:25
    关注

    JSP:

    String[] stringArray = url.split("/"); 
    

    PHP: You already have it...

    $parts = explode('/', $url);
    

    ASP: I don't know ASP, but here is what google found:

    parts = Split(url, "/");
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示
  • ¥15 求三国群英传pl国战时间的修改方法
  • ¥15 matlab代码代写,需写出详细代码,代价私
  • ¥15 ROS系统搭建请教(跨境电商用途)
  • ¥15 AIC3204的示例代码有吗,想用AIC3204测量血氧,找不到相关的代码。