Gayan Hewa
Gayan Hewa

Reputation: 2397

Struts 2 and Tiles with Netbeans

I am trying get Struts 2 and Tiles to work and I am using netbeans 7.1 as my IDE. Most of the examples are built on eclipse and I can seem to find a working example , So i tried to follow a tutorial And tried to get it sorted. Now I have the proeject runningwell and I can access individual tiles by url.

ie. http://localhost:8088/sample2/example/body.jsp

But the action to mapping doesnt seem to work.

below are the files :

struts.xml = http://pastebin.com/5uWLSXWj example.xml = http://pastebin.com/UQh68YNE web.xml = http://pastebin.com/ZgVXfW1E LinkAction.Java = http://pastebin.com/8cvKdmai

Appreciate any guidance , and links to netbeans and struts 2 example code.

Upvotes: 1

Views: 1784

Answers (1)

tusar
tusar

Reputation: 3424

<package name="example" namespace="/example" extends="struts-default">

Problem with Struts.xml file. You are loading two <package>s with same configuration.

Thats why one package is loading(with plain JSP result), and another is silently dropped (with Tiles results.) Try combining them into one, like this :

<struts>
<package name="example" namespace="/example" extends="struts-default">
    <result-types>
            <result-type name="tiles" class="org.apache.struts2.views.tiles.TilesResult" />
    </result-types>
    <action name="HelloWorld" class="example.HelloWorld">
        <result>/example/HelloWorld.jsp</result>
    </action>
    <action name="Body" class="example.HelloWorld">
        <result>/example/body.jsp</result>
    </action>              

    <action name="*Link" method="{1}" class="example.LinkAction">
            <result name="welcome" type="tiles">welcome</result>
            <result name="friends" type="tiles">friends</result>
            <result name="office" type="tiles">office</result>
    </action>  
</package>
</struts>

Upvotes: 1

Related Questions