【发布时间】:2017-07-24 15:59:39
【问题描述】:
class InstitutionController extends Controller {
def updateInstitution = Action { implicit request =>
{
request.body.asJson.get.validate[GallreyJsonValidationForUpdate].fold(
valid = {
updateInstitution =>
{
Redirect(routes.GalleryController.updateGallreyObject()).flashing("uuid"- >updateInstitution.uuid,"institutionName"->updateInstitution.institutionName,"details"->updateInstitution.details)
}
},
invalid = {
errors =>
{
val json=commonUtils.getResponse(Http.Status.BAD_REQUEST, ServerResponseMessages.VALIDATION_FAILED,JsError.toJson(errors))
log.error("sending error in json{}", json)
BadRequest(json)
}
})
}
}
这是我要重定向到的操作
class GalleryController extends Controller {
def updateGallreyObject = Action { implicit request =>
{
val uuid=request.flash.get("uuid")
val institutionName=request.flash.get("institutionName")
val details=request.flash.get("details")
Ok("some details")
}}
}
这是我正在使用的 curl 文件
contentType="Content-type: application/json";
data='{ "uuid" : "123" , "institutionName" : "abc" , "details" : "some details"
}';
echo " "
echo "------------------ Sending Data ------------------"
echo " "
echo "Content-Type : " $contentType
echo "Data : " $data
echo " "
echo "------------------ Response ------------------"
echo " "
echo " "
curl --include --request POST --header "Content-type: application/json" --data "$data" http://localhost:9000/institution/update
我得到的回应是
HTTP/1.1 303 See Other
Location: /gallery/update
Set-Cookie: PLAY_FLASH=uuid=123 &institutionName=abc&details=some+details; Path=/; HTTPOnly
Date: Sat, 04 Mar 2017 14:40:29 GMT
Content-Length: 0
这是路线
POST /institution/update controllers.InstitutionController.updateInstitution
为什么它不重定向到 updateGallreyObject Action ?我做错了什么请帮忙,我希望它重定向到updateGallreyObject 数据操作请帮忙,我期待这个回复“一些细节”
更新我已经有了这条路线
POST /gallery/update controllers.GalleryController.updateGallreyObject
【问题讨论】:
标签: scala playframework playframework-2.2 playframework-2.3