简体   繁体   English

Struts1.2动作类未调用

[英]Struts1.2 action class is not called

Here i am giving my code i am not getting output but action is called but action class is not called. 在这里,我给出的代码没有得到输出,但调用了动作,但未调用动作类。 what i suppose to do please help me. 我想做的事请帮助我。 and what i am getting in url is 我在URL中得到的是

http://vpcl014:8080/StrutsExamples/loginPojoClass.do

but my file is not displaying and the actioncalss is not calling. 但是我的文件没有显示,并且actioncalss没有调用。 what i should do :( PojoClass. 我应该怎么做:( PojoClass。

import org.apache.struts.action.ActionForm;

public class LoginPojo extends ActionForm {

    /**
     * 
     */
    private static final long serialVersionUID = 962636910569104889L;
    private String username;
    private String password;

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

}

Action Class: 动作类:

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;    
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;


// action mapping class for the action.
public class Pojoaction extends Action {

    // method for the mapping the action.
    public ActionForward execute(ActionForm form, ActionMapping mapping,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {

        System.out.println("Action is called..:D");
        LoginPojo loginPojo = new LoginPojo();
        loginPojo.setUsername("Username");
        loginPojo.setPassword("Password");
        return mapping.findForward("success");
    }

}

struts-cfg.xml file is here. struts-cfg.xml文件在这里。

<form-beans>
    <form-bean name="LoginPojo" type="com.kishan.modelPojo.LoginPojo"></form-bean>
    <form-bean name="LoginPojoSuccess"
        type="com.kishan.modelPojo.LoginPojo.LoginPojoSuccess"></form-bean>
</form-beans>
<action-mappings>
    <action path="/Forword" forward="/LoginPojo.jsp"></action>
    <action name="LoginPojo" path="/loginPojoClass" scope="session"
        type="com.kishan.modelPojo.Pojoaction" input="/LoginPojo.jsp"
        validate="false">
        <forward name="success" path="/LoginPojoSuccess.jsp"
            redirect="true">
        </forward>
    </action>
</action-mappings>
<message-resources parameter="com.kishan.struts.ApplicationResources" />

my jsp file where i am calling that method. 我在jsp文件中调用该方法的位置。

    <body>
        <html:form action="/loginPojoClass">
            Username:<html:text property="username"></html:text>
            <br />
            Password:<html:password property="password"></html:password>
            <br/><html:submit value="Submit"></html:submit>
        </html:form>

        This is my JSP page.
        <br>
    </body>
</html>

finally my index.jsp where i am putting my first forward action 最后是我的index.jsp,这是我的第一个前进动作

 <html>
    <head>
        <base href="<%=basePath%>">

        <title>My JSP 'index.jsp' starting page</title>
        <meta http-equiv="pragma" content="no-cache">
        <meta http-equiv="cache-control" content="no-cache">
        <meta http-equiv="expires" content="0">
        <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
        <meta http-equiv="description" content="This is my page">
        <!--
    <link rel="stylesheet" type="text/css" href="styles.css">
    -->
    </head>

    <body>
        <html:link action="/Forword.do">GOTO FORM</html:link>

        <br>
    </body>
</html>

i Dont know how its done but i found solution for the same. 我不知道它是如何完成的,但是我找到了解决方案。

by replacing some parameter into the method. 通过将一些参数替换为方法。 that is. 那是。

i replace ServletRequest to the HttpServletRequest and have used override notation to over ride class method. 我将ServletRequest替换为HttpServletRequest,并使用了覆盖符号来替代类方法。 and it gets solved i dont know stil reason how.. 它得到解决,我不知道stil原因如何..

@override
public ActionForward execute(ActionForm form, ActionMapping mapping,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception() {

}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM