Pretty url with routing

Hey there!

I’ve tried to use some pretty urls in my plugin. But I don’t know where and how I have to put the xml in atlassian-plugin.xml

I want to use an url like /jira/plugins/servlet/story/1-1
As I understand I have to use routing module:

<routing key="prettyurls-key" path="/plugins/servlet">
        <route from="/story/{product}-{story}" to="/story?productId={product}&amp;storyId={story}" />
</routing>

Have I to put this code inside the servelet-declaration or outside?

kind regards - Sven

I hope this example is illustrative:

    <servlet name="Servlet" key="servlet" class="com.mycompany.jira.MyServlet">
        <description>Provides pages for the URL provided.</description>
        <url-pattern>/my-servlet*</url-pattern>
    </servlet>

    <routing name="Pretty URL" key="routing" path="/my-servlet">
        <description>Customizes the URL.</description>
        <route from="/" to="/plugins/servlet/my-servlet"/>
        <route from="/{page}" to="/plugins/servlet/my-servlet/{page}"/>
    </routing>

    <sitemesh name="Sitemesh" key="sitemesh" path="/my-servlet">
        <description>Provides decoration for our custom URL.</description>
    </sitemesh>

Hello, do you know how to pass the page parameter from the Servlet class? What do I have to type in the Servlet class so that the plugin puts the page value into the URL? @steve.behnke

It’s really difficult to understand your question, especially regarding the topic here of Pretty URLs.

If possible, please raise a new question and include detailed examples about what you’re doing and what you’ve tried.

The Atlassian plugin framework is really simply just using Java Servlets so you should be able to apply any lesson you find Online about Java Servlets to this case.

1 Like