我如何在我的grails应用程序中使用servlet? [英] How do i use a servlet in my grails app?
问题描述
我需要使用一些实际上是servlet的连接器。我如何在Grails中做到这一点,web.xml呢?如何配置servlet的url?
实际上,我在这里有一个Spring应用程序,我试图将它转换为部分Grails应用程序。我在spring-app中有一个连接器servlet,我希望在这里使用它,但映射必须在gsp文件中调用servlet。我怎样才能做到这一点?我基本上需要知道在Grails情况下XML文件的位置。
为了获得 web .xml
文件,您可以运行: grails install-templates
然后,该文件可以在以下位置找到:
< yourapp> /src/templates/war/web.xml
编辑此像往常一样添加< servlet>
和< servlet-mapping>
部分,然后将您的servlet代码放入:
< yourapp> src / java / your / package / structure / WhateverServlet.java
你应该很好去
I need to use some connectors which are actually servlets. How can I do this in Grails and what about the web.xml? How do I configure the url of the servlet?
I actually have a Spring application here and I am trying to convert it into a partial Grails app. I have a connector servlet in the spring-app, which I wish to use here but the mapping is a must to call the servlet in the gsp file. How can I do this? I basically need to know where the xml file is in case of Grails.
To get the web.xml
file, you can run:
grails install-templates
Then, the file can be found in:
<yourapp>/src/templates/war/web.xml
Edit this as usual to add <servlet>
and <servlet-mapping>
sections, then put your servlet code in:
<yourapp>src/java/your/package/structure/WhateverServlet.java
and you should be good to go
这篇关于我如何在我的grails应用程序中使用servlet?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!