angularjs - 运行应用程序中的 Grails 3.0 静态 html

标签 angularjs grails

之前也有人问过类似的问题,关于 grails 2(.3, .4)。我觉得奇怪的是我找不到这样做的方法,因为这对我来说似乎是一个标准用例。

我只想在运行 grails run-app 时提供 html 页面,包括它们链接的 .css 和 .js(angular 和 jquery 内容)。

我想检查我的 http 调用是否在双方正确处理 - 无需部署 .war 和配置数据库。

afaik grails run-app 只是启动一个码头/tomcat - 这两个显然都可以提供 .html 页面。我该怎么做才能让 grails 开发工具部署我的文件?

我需要发出http请求,
所以使用不同的服务器会违反 JS-SOP,
部署 .war 会大大减慢开发过程

到目前为止,我只找到了笨拙的 jsonp、代理、.war 部署解决方案或 grails 2.x 解决方案

我尝试将文件放在项目结构中的任何地方( /src/main/src/main/resources/src/main/public 、assets 文件夹及其子文件夹,在每个子目录、Init、域、conf 目录中创建了 web-app 目录 - 你命名)

最佳答案

添加 index.htmlsrc/main/resources/public
然后将此添加到 UrlMappings.groovy :

"/"(redirect:"/index.html")

对于 grails >= 3.0.12

Location of static resources

In order to resolve an issue around how POST requests are treated for REST applications on non-existent resources, static resources located in src/main/resources/public are now resolved under the /static/** URI by default, instead of the base URI /**. If you wish to restore the previous behaviour add the following configuration:

grails.resources.pattern = '/**'



https://github.com/grails/grails-core/releases/tag/v3.0.12

关于angularjs - 运行应用程序中的 Grails 3.0 静态 html,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31402428/

相关文章:

javascript - 我可以让 AngularJS 为 Facebook OpenGraph 抓取工具使用不同的 Controller 吗?

javascript - AngularJS ag-grid 调整大小后获取列宽

angularjs - Angular 与微数据

grails - 无法在我的Ubuntu计算机上从GVM安装Grails; gvm安装grails不起作用

javascript - Grails:如何使 g:textfield 自动完成?

css - Bootstrap 3 Glyphicons 未显示在 Grails GSP 页面中

grails - 在HQL查询中执行加/减?

html - nggrid 表格高度修复为 18 像素错误

JavaScript - 减慢循环速度

session - 从Spring安全 session 序列化中排除属性?