本文介绍了运行应用程序中的Grails 3.0静态html的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

关于grails 2(.3,.4),曾有人问过类似的问题.我发现无法找到一种方法来做这件事很奇怪,因为这对我来说似乎是一个标准的用例.

我只想在运行grails run-app时提供html页面,包括它们链接的.css和.js(角度和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应用程序目录目录-您命名)

解决方案

index.html添加到src/main/resources/public

然后将其添加到UrlMappings.groovy:

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


对于grails> = 3.0.12

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

similar questions have been asked before, regarding grails 2(.3, .4). I find it strange that i could not find a way to do this, as it seems a standard use-case to me.

I simply want to serve html-pages, including their linked .css and .js (angular and jquery content) when i run grails run-app.

I want to check if my http-calls are handeled correctly on both sides - without needing to deploy a .war and configuring a database.

afaik grails run-app simply starts a jetty/tomcat - both of which can obviously serve .html pages. What do i have to do to make the grails development-tooling deploy my files?

I need to make http-requests,so using a different Server would violate JS-SOP,while deploying the .war would greatly slow down the development process

I've so far only found clunky jsonp, proxy, .war deployment solutions, or solutions for grails 2.x

I tried placing the files literally everywhere in the projects' structure (/src/main, /src/main/resources, /src/main/public, the assets folder and its subfolders, created web-app directories in every subdirectory, the Init, domain, conf directories - you name it)

解决方案

Add the index.html to src/main/resources/public

Then add this to UrlMappings.groovy:

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


For grails >= 3.0.12

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

这篇关于运行应用程序中的Grails 3.0静态html的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-20 15:35