Tomcat, Groovy and clean urls -


I am trying to run inside Groovy Tomcat with a clean URL. Since my knowledge of Tomcat's URL mapping and filter is quite limited, so I'm walking in a brick wall.

What do I need to do index.groovy called FrontController which handles incoming requests The problem is that I can not understand that the correct web.xml How to create a mapping I currently have (which is a lot more standard):

  & lt; Servlet & gt; & Lt; Servlet-name & gt; Groove & lt; / Servlet-name & gt; & Lt; Servlet category & gt; Groovy.servlet.GroovyServlet & lt; / Servlet category & gt; & Lt; / Servlet & gt; & Lt; Servlet-mapping & gt; & Lt; Servlet-name & gt; Groove & lt; / Servlet-name & gt; & Lt; URL pattern & gt; / * & Lt; / URL pattern & gt; & Lt; / Servlet-mapping & gt;  

If I try to use my URL now with the URL, then I get a 404 .

  http: // localhost: 8080 / grooveist / index.groovy / test  

Of course, ideally I have index.groovy I want to execute the script where I can choose the rest of the way

I think the main problem here is how both servlet GroovyServlet works mapping, therefore, here A brief description is given:

  • When you describe such mappings, it indicates that all URLs matching the "/ *" pattern will be sent to the Groovasverget class . With this kind of general pattern, all the URLs are valid, causing some issues, for example when trying to use images, styles, etc. ...
  • GroovyServlet already The only one is the sender if you see this source code, you will see that, due to its legacy, it will only check that the path given under the "/ WEB-INF / groovy /" directory is present. In your example, this means that it appears for the file "/WEB-INF/groovy/index.groovy/test"
  • If this file exists, then it is executed as a Groovy script Goes (with some decorator), and the result is returned with the "text / html" mime type.

Now I think that you can clearly understand why this does not work on your example. I would like to suggest two more ways to achieve your goals:

  • See at a glance, this is one of the most appropriate frameworks for web development in Groovy.
  • The source of the micro-framework is not only a good start to understand how a removable work is done, but there is also a good tutorial to help you manage a clear URL
  • < / Ul>

Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -