Can struts.xml and struts annotation be used at the same time

162 Views Asked by At

I am using two action classes in my application, i am using annotation in one action class and i want to use struts.xml for the other action class. Is it possible. When i am using annotation, this is working

@Namespace("/")
@ResultPath("/")
public class StartQuizAction extends ActionSupport {
    private static final long serialVersionUID = 953099491763814636L;
    private List qlist;
    public List getQlist() {
        return qlist;
    }
    public void setQlist(List qlist) {
        this.qlist = qlist;
    }
    public static long getSerialversionuid() {
        return serialVersionUID;
    }
    @Action(value="startQuiz" ,results={@Result(name="success" , location="User/pages/qData.jsp")
            })
    public String execute(){
        System.out.println("in 2nd action");
        QuizDataInput qData= new QuizDataInput();
        qlist=qData.getData();
        System.out.println(qlist);
        return SUCCESS;
    }
}

But when i use struts.xml, removing annotations, i am getting this error

There is no Action mapped for namespace [/] and action name [] associated with context path [/quizcreator]. - [unknown location]

Struts.xml

<struts>
    <package name="default" namespace="/" extends="struts-default">
        <action name="startQuiz" class="com.agc.onlinequiz.action.StartQuizAction">
            <result name="success">User/pages/qData.jsp</result>
        </action>
    </package>
</struts> 
0

There are 0 best solutions below