저는 매우 오래된 J2EE/struts 사이트에서 작업하고 있으며 최근에 PayPal에서 SSL 3 프로토콜 지원 중단으로 인해 새로운 호스트 체크 아웃 프로세스를 구현하려고합니다. 지불 게이트웨이는 주문 세부 정보가 포함 된 POST를 수락하고 신용 카드 유효성 검사를 처리하며 다른 POST를 통해 응답 코드 (및 기타 다른 값)를 반환합니다.Struts 액션이 컨트롤러 변경 후 올바른 경로를 렌더링하지 않습니다.
struts에서 기존 작업을 활용하려하지만 struts-config.xml에 지정된 경로 (/store/order/confirmation.do)이 렌더링되지 않기 때문에 중단됩니다. 대신 원격 서버의 POST 요청이 처리되고 ActionMapping.findForward()가 호출 된 후 응용 프로그램은 POST에서 원격 서버의 요청과 동일한 경로를 렌더링합니다. (/store/checkout/submitOrder.do).
struts-config.xml에서 forward에 redirect = "true"를 추가하려고하면 올바른 경로로 리디렉션되지만 pagecontext 예외가 발생하여 로그되지 않아 디버깅 할 수 없습니다.
작동 방식은 submitOrder 양식이 비어있는 것입니다. 단지 제출 입력입니다. 그런 다음 세션 기반 쇼핑 카트 및 관련 고객 청구서의 체크 아웃 세부 정보가 특수한 버전 라이브러리로 전달되어 응답을 생성합니다. 이제 새 공급자의 POST 양식을 사용하려고하지만이 리디렉션 실패로 인해 막혔습니다.
스트럿 - config.xml 파일의 행은 다음과 같습니다
<action path="/store/checkout/submitOrder" type="com.company.action.CheckoutAction" parameter="submitOrder" scope="request">
<set-property property="secure" value="true"/>
<forward name="success" path="/store/order/confirmation.do"/>
</action>
를 그리고 작업은 다음과 같이 진행됩니다
public ActionForward submitOrder(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
String method = request.getMethod();
if (method != null && method.equals("POST")) {
ShoppingCart sc = (ShoppingCart) request.getSession(false).getAttribute("shoppingCart");
if (sc == null) { throw new SessionExpiredException("Submit Order - Shopping Cart is not in session"); }
ResourceBundle appConfig = ResourceBundle.getBundle("resources.application");
PFProClient client = new PFProClient();
/* THIS saveOrder() METHOD WAS RE-WRITTEN TO TAKE the httpservletrequest (form POST) instead of an instance of VerisignResponse, defined in another library. */
client.saveOrder(sc, request);
User user = (User)request.getSession(false).getAttribute(Globals.USER);
if (user != null) { UserModel.saveUser(user, sc.getCustomer(), sc.getOrder()); }
//Remove items from session
request.getSession().setAttribute("customerBillingForm", null);
request.getSession().setAttribute("customerShippingForm", null);
request.getSession().setAttribute("customerCreditForm", null);
request.getSession().setAttribute("cartForm", null);
request.getSession().setAttribute("shoppingCart", null);
//remove the shopping cart from the cookie & DB
ShoppingCartUtils.deleteSavedCartFromCookie(response, request);
//remove the CHECKING_OUT flag
request.getSession().setAttribute(Globals.CHECKING_OUT, null);
//remove the PAYING_WITH_PAYPAL flag
request.getSession().setAttribute(Globals.PAYING_WITH_PAYPAL, null);
// Set cart in request for order confirmation page
request.setAttribute("shoppingCart", sc);
return mapping.findForward("success");
} else {
// HTTP method was not POST
}
return mapping.findForward("success");
}
편집 나는 것을 확인했습니다
submitOrder 조치가 POST 요청으로 처리 중입니다. 나는 이전 POST가 단지 빈 폼 이었기 때문에 여분의 POST 매개 변수가 뭔가를 오염시키고 적절한 라우팅을 방해하는지 궁금합니다.
타일 - defs.xml에서상기 confirmation.do보기위한 자원이다
<definition name="confirm.order" path="/templates/layouts/order-confirmation.jsp">
...
<put name="content" value="/store/checkout/confirmOrder.jsp"/>
</definition>
애플리케이션은 confirmOrder.jsp 뷰를 제공하지만/저장/주문/확인 라우팅되지 .do가 없으므로 페이지를 다시로드하려고하면 양식을 다시 제출하라는 메시지가 표시됩니다. 이는 분명히 바람직하지 않습니다.
struts-config.xml에 submitOrder 액션 정의에서 name = "emptyForm"에 대한 참조를 삭제했습니다. (원격 서버에서 오는 POST 양식은 emptyForm 이름 속성을 갖지 않으므로) :
나는 어느 효과가 있을지 모르겠습니다.
나는 완전히 틀렸어. 모든 것이 적절하게 전달됩니다! 나는 라우팅이 /store/order/confirmation.do를 해결할 것이라고 생각했지만 실제로 submitOrder.do로가는 것으로되어있다! – Thom