我正在使用下面的代码来重写我的URL。每次我点击它的作品文件链接,都会将EXTRA Profile/view添加到地址的末尾。如何更改我的代码以使用tiles和struts2正确地实现url重写
http://www.example.com/myProject/Profile/view.action
我第一次在视图中单击它,它变成
http://www.example.com/myProject/Profile/Profile/view.action
后,如果我再次点击视图这将是(每次我点击就将此一/个人资料的地址)
http://localhost:8080/myProject/Profile/Profile/Profile/view.action
链接
<a href="<s:url action="Profile/view"/>" >Profile</a>
struts.xml的
<package name="default" extends="struts-default">
<result-types>
<result-type name="tiles" class="org.apache.struts2.views.tiles.TilesResult"/>
</result-types>
<action name="index">
<result type="tiles">content</result>
</action>
</package>
<package name="Profile" extends="default" namespace="/Profile">
<action name = "*" method="{1}" class="com.myproject.Profile">
<result name="View" type="tiles">Profile</result>
<result name="Edit" type="tiles">Edit</result>
</action>
</package>
的问题是,每次我在视图中单击它不会删除该地址,并添加配置文件/视图,以它的结束。它只是将地址从www.example.com/myproject/profile/view更改为www.example.com/myproject/profile/profile/view
我不明白如何重写这个。有什么问题? – 2013-02-15 01:06:31
嗨,戴夫,我在前面的问题中遵循了你的回答,但是如第一次解释的那样,但我每次点击视图都会在地址末尾添加一个额外的配置文件/视图。 – 2013-02-15 01:07:45