You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

ExtJS:如何为sencha web start命令指定目标URL?

指定Sencha Web Server启动后的目标URL

你可以通过以下几种方式实现需求:

  • 启动时自动打开指定URL
    使用--open参数直接指定要打开的完整URL,注意在shell中处理特殊字符(比如&)时需要转义或用引号包裹:

    # 转义&符号
    sencha web -port 3888 start --open http://localhost:3888/WebContent/My.cgi?lang=en\&test=true
    
    # 或者用引号包裹整个URL
    sencha web -port 3888 start --open "http://localhost:3888/WebContent/My.cgi?lang=en&test=true"
    

    执行后会自动在默认浏览器中打开目标地址。

  • 配置默认路由重定向
    如果需要长期固定默认访问路径,可在项目的.sencha/web目录下创建或修改web.xml文件,添加重定向规则:

    <web-app>
        <redirect from="/" to="/WebContent/My.cgi?lang=en&test=true"/>
    </web-app>
    

    之后启动服务sencha web -port 3888 start,访问http://localhost:3888就会自动跳转到目标URL。

  • 手动访问目标URL
    直接启动服务后,在浏览器地址栏输入完整的目标地址http://localhost:3888/WebContent/My.cgi?lang=en&test=true即可,只要你的项目中存在对应的WebContent/My.cgi资源,就能正常访问。

内容的提问来源于stack exchange,提问作者harunB10

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.13 00:15:30