2011-03-25 19 views
0

The following code is giving error as:<a href> tag

There is no Action mapped for namespace/and action name .

code: .jsp file:

<a href="<s:url action='DisconnectAction' />">Disconnect</a> 

struts.xml

<action name="DisconnectAction" class="ActionPackages.DisconnectAction"> 
    <result name="success">/JSP/mytemplate.jsp</result> 
    <result name="input">/JSP/mytemplate.jsp</result> 
    <result name="error">/JSP/mytemplate.jsp</result> 
    <result name="failure">/JSP/mytemplate.jsp</result> 
</action> 

I want to perform action and keep the current accessing page only which is mytemplate.jsp

답변

0

Though your question is not clear so better give details about the problem but if i read the subject you want to call action using so here is the struts2 standard way

<s:a cssClass="table_tabs_dis" href="%{GenURL}">General</s:a> 

and here is one more

<a href="<s:url action=MyAction" namespace="/abc/xyz" />">ClickME</a> 
+0

Hi i changed the code and it worked fine instead of writing as Disconnect을 사용하여 액션 클래스를 호출하는 방법 Disconnect pankaj

0

According to your question the problem was in your <s:url/> tag you have to give action after DisconnectAction & it will work fine as you want.

<a href="<s:url action="DisconnectAction.action"/>">Disconnect</a> 

Struts.xml

<action name="DisconnectAction" class="ActionPackages.DisconnectAction"> 
    <result name="success">/JSP/mytemplate.jsp</result> 
    <result name="input">/JSP/mytemplate.jsp</result> 
    <result name="error">/JSP/mytemplate.jsp</result> 
    <result name="failure">/JSP/mytemplate.jsp</result> 
</action> 
+0

으로 작성했습니다. 이것이 사실이라고 생각하지 않습니다. 액션 확장은 ''태그에 필요하지 않아야합니다. –

0

It seems that you have not given ".action " extension in struts tag. When you are using

<s:form action="someAction"></s:form> 

you dont need to give .action extension to your action name. But since you are embedding it in HTML tag, you have to give .action Extension.

(Answer Verified on Live)

<a href="<s:url action="urlTagAction.action" />"> Disconnect </a> 
관련 문제