이전에 본 적이 없으므로 도움을 요청하고 있습니다.양식을 제출할 때 Play Framework POST 경로가 실행되지 않습니다.
나는 그것을위한 POST 경로를 시작하지 않을 제출 버튼이있는 간단한 하나의 필드 형식을 가지고 있습니다. 이 코드는 며칠 전에 작동했지만 지금은 계속해서 GET 라우트를 실행합니다. POST 경로와 호출하는 함수에 결코 도달하지 않으므로 오류가 없습니다. ,
public Result ptpCreate() {
// Set some needed values...
List<Lookup> lookups = Lookup.find.all();
List<User> users = User.find.all();
// Sort the lists...
AppGlobals sortThis = new AppGlobals();
Collections.sort(users, sortThis.new sortUsers());
Collections.sort(lookups, sortThis.new sortLookups());
return ok(adult1.render(form(PTPForm.class), lookups, users));
}
public Result ptpSave() {
Form<PTPForm> ptpEntry = form(PTPForm.class).bindFromRequest();
if (ptpEntry.hasErrors()) {
List<Lookup> lookups = Lookup.find.all();
List<User> users = User.find.all();
Logger.debug("Save ptp - errors");
// Sort the lists...
AppGlobals sortThis = new AppGlobals();
Collections.sort(users, sortThis.new sortUsers());
Collections.sort(lookups, sortThis.new sortLookups());
return badRequest(adult1.render(ptpEntry, lookups, users));
}
String userkey = AccessMiddleware.getSessionUserKey();
User user = null;
user = User.findByUserKey(userkey);
// Save the PTP record....
PTP ptp = new PTP();
PTPForm ptpForm = ptpEntry.get();
ptp.setLegacy_Provider_Id(ptpForm.legacy_Provider_Id);
ptp.save();
return ok(ptpcreated.render(ptp.getPtpkey()));
}
나는 계속 버튼을 클릭하면 :
여기@(ptpForm: Form[Application.PTPForm], lookups: java.util.List[Lookup], users: java.util.List[User])
@main(null) {
<section id="ptpCreated">
<form class="formoid-solid-dark"
style="background-color: #FFFFFF; font-size: 14px; font-family: 'Trebuchet MS', 'Roboto', Arial, Helvetica, sans-serif; color: #34495E; max-width: 480px; min-width: 150px"
method="get" action="">
<div class="title">
<h3>Success</h3>
</div>
<div class="element-number" title="This is the eight-digit Provider ID number that you used for this setting in the portal maintained by Xerox. You may have had different Provider IDs for different services, settings, and/or waivers. Cannot be blank - numbers only">
<label class="title"><span class="required">* Legacy Provider Id...</span></label>
<div class="item-cont"><input type="text" name="legacy_Provider_Id" class='allow_numeric' required="required" min="1" max="99999999" maxlength="8" placeholder=""/><span class="icon-place"></span></div>
</div>
<div class="submit">
<input type="submit" value="Continue" />
</div>
<!-- This is needed for bottom shadow to appear... -->
<div></div>
</form>
</section>
}
컨트롤러의 기능은 다음과 같습니다 여기 형태입니다
GET /createptp controllers.Application.ptpCreate()
POST /createptp controllers.Application.ptpSave()
:
여기 경로입니다 그냥 ptpCreate()
함수로 돌아가고 POST 경로도 신경 쓸 필요가 없습니다.
저는 행운이없는 clean
과 compile
을 수행했습니다.
<form action>
을 action="@routes.Application.ptpSave()"
으로 변경해 보았습니다.
추적 할 오류가 없으므로이 코드는 완전히 손실됩니다.
시도해 볼 수있는 한 가지 방법은 브라우저 개발 도구 (FF의 네트워크 탭)를 사용하는 것입니다. 게시물 요청을 제출하면 어떻게됩니까? 어떤 반응을 보이고 있습니까? – jrook
또한'form' 태그에서'method = "get"action = "">'을 제거하고 적절한 행동 경로를 대신 사용하십시오. – jrook
'