简体   繁体   English

可从Deployed应用程序访问Grails WEB-INF

[英]Grails WEB-INF accessible from Deployed app

In grails application, one can access the WEB-INF contents including all the .gsp content as well as .class file when deployed. 在grails应用程序中,可以访问WEB-INF内容,包括所有.gsp内容以及部署时的.class文件。

I am using grails 2.3.5 and deploying the war in the tomcat 7. 我正在使用grails 2.3.5并在tomcat 7中部署战争。

You can access the files using 您可以使用访问这些文件

http://mydomain.com/static/WEB-INF/web.xml http://mydomain.com/static/WEB-INF/web.xml
http://mydomain.com/static/WEB-INF/grails-app/views/anyview.gsp http://mydomain.com/static/WEB-INF/grails-app/views/anyview.gsp
http://mydomain.com/static/WEB-INF/grails-app/i18n/messages.properties http://mydomain.com/static/WEB-INF/classes/anyclass.class http://mydomain.com/static/WEB-INF/grails-app/i18n/messages.properties http://mydomain.com/static/WEB-INF/classes/anyclass.class

Can I disable access to these url in grails? 我可以禁止访问grails中的这些URL吗?

In grails by default, there is resources plugin. 默认情况下,在grails中有资源插件。 And it maps all the resources such as css, js, images, WEB-INF, plugins and META-INF which you will find when you extract war file. 它会映射所有资源,如css,js,图像,WEB-INF,插件和META-INF,您将在提取war文件时找到它们。

You need to include following line in your config.groovy to include just css, js and images in static resources. 您需要在config.groovy中包含以下行,以便在静态资源中包含css,js和images。

grails.resources.adhoc.includes = ['/images/**','/js/**','/css/**']

You can also use : 您还可以使用:

grails.resources.adhoc.excludes = ['/WEB-INF/**']

to exclude only WEB-INF. 仅排除WEB-INF。

I don't know whether I should say for more information or just for information. 我不知道我是应该说更多信息还是仅仅是为了获取信息。 Anyway you can also find some information of this in documentation of resources plugin in configuration part which has title 无论如何,你也可以在配置部分的资源插件文档中找到一些有关标题的信息

Controlling the includes and excludes of the adhoc filter: grails.resources.adhoc.includes/excludes 控制adhoc过滤器的包含和排除:grails.resources.adhoc.includes / exclude

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM