액션 서블릿 createLabel.do를 호출하려고하는데 액션 클래스가 호출되지 않는 것처럼 보입니다. 난 방화 광을 사용하여 디버깅하고 그것은 URL이 호출 된 것처럼 보이지만 수신 응답이 없습니다. 여기 Struts 액션에 대한 Ajax 호출이 응답을 반환하지 않습니다.
public class CreateLabelAction extends Action{
public ActionForward execute (ActionMapping mapping, HttpServletRequest request, HttpServletResponse response){
String label = request.getParameter("label");
String lab_no = request.getParameter("lab_no");
String accNum = request.getParameter("accNum");
response.setContentType("application/json");
try {
DB db = new DB(DB.DATA);
Connection conn = db.GetConnection();
String insertstmt = "update Info set label='"+label+"' where lab_no="+lab_no+" and accNum='"+accNum+"'";
logger.info(insertstmt);
PreparedStatement pstmt = conn.prepareStatement(insertstmt);
pstmt.executeUpdate();
pstmt.close();
db.closeConn();
logger.info("Label created successfully.");
} catch (Exception e){
logger.error("Error inserting label into Info" + e);
request.setAttribute("error", "There was an error creating a label.");
}
logger.info("Label ="+label);
label = StringEscapeUtils.escapeJavaScript(label);
return mapping.findForward("complete");
}
}
이 스트럿 - config.xml 파일의 구성은 다음과 같습니다 :
<script type="text/javascript" charset="utf-8">
$(function() {
$("#createLabel").click(function() {
$.ajax({
type: "POST",
url: "/createLabel.do",
dataType: "json",
contentType: "application/json; charset=utf-8",
data: { lab_no: $("#labNum").val(),accNum: $("#accNum").val(), label: $("#label").val() },
success: function() {
alert("success");
}
});
});
});
</script>
가 여기 내 액션 클래스의 :
다음은 자바 스크립트 함수의
<action input="/labDi.jsp" name="LabelForm" path="/createLabel" scope="request" type="all.pageUtil.CreateLabelAction">
<forward name="complete" path="/labDi.jsp" />
</action>
누군가가 말해 주시겠습니까 이유 액션 클래스가 유발되지 않았습니까? 미리 감사드립니다.
'#의 createLabel'는 DOM 요소의 유형은 무엇입니까? 제출 버튼, 링크, 표준 버튼, div, ...? –
표준 단추 : – Sapphire
이 단추는 양식 안에 있습니까? FireBug에서 버튼을 클릭하면 무엇을 볼 수 있습니까? AJAX 요청이 전송됩니까? –