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
相关产品推荐
相关产品推荐

