EXTJS servlet无法正常工作

时间:2013-08-16 20:50:55

标签: java javascript servlets extjs

我似乎无法弄清楚为什么servlet无法正常工作。 当我按下extjs时,它没有拾取任何东西。我有一个控制器peopleTemplate,它充当servlet,并进行查询。

下面是我的servlet

public class peopleTemplate extends HttpServlet {
private static final long serialVersionUID = 1L;


protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException,
        IOException {
    PrintWriter out = response.getWriter();
    String action = request.getParameter("action");
    String firstname = request.getParameter("firstname").trim();
    if(action.equals("add")) {
        ExecuteQuery sq = new ExecuteQuery();


    }

    ExecuteQuery sq = new ExecuteQuery();

    String confirmUpdate = null;
    confirmUpdate = sq.peopleTemplate(firstname);

    // return delete confirmation
    response.setContentType("text/html");
    out.print(confirmUpdate);


}

}

以下是我执行的查询

public ExecuteQuery() {
    try {
        conn = DBConnect.getInstance().dbOracleConnect();
    } catch (Exception e) {
        e.printStackTrace();
        logger.error("Database Connection error: " + e);
    }
}


public String peopleTemplate(String firstname) {

    String result = null;
    String query = "INSERT INTO ts_people SET firstname =?" ;

    try {
        ps = conn.prepareStatement(query);
        ps.setString(1, "0");
        ps.setString(2, firstname);

        int numberOfRowsAffected = ps.executeUpdate();
        if (numberOfRowsAffected == 1) {
            result = "Bid Number " + firstname + " activated.";
        } else {
            result = "Update failed: Bid Number " + firstname + " not found.";
        }

    } catch (Exception e) {


}
    return result;
}

}

这是javascript文件中的按钮

   buttons: [{
        text: 'Save',
           handler: function(){
    Ext.Ajax.request({
        url : 'src/javas/peopleTemplate',
        method: 'POST',                   
        params :{'firstname': firstname},       
        success: function ( result, request ) {
            resultData = result.responseText;
            Ext.MessageBox.show({title:'Delete Status ', msg: resultData, buttons: Ext.MessageBox.OK, icon: Ext.MessageBox.INFO});              

        },
        failure: function ( result, request ) {
            Ext.MessageBox.show({title:'Delete Status ', msg: 'Request failed.', buttons: Ext.MessageBox.OK, icon: Ext.MessageBox.INFO});               

        }   
    });

按保存时为什么没有出现?

0 个答案:

没有答案