이미지 업로드 기능이 필요한 응용 프로그램을 만들고 있습니다. 나는 this 자습서와 App Engine Documentation을 따라 왔습니다.GAE 및 GWT - response.sendRedirect가 리디렉션되지 않습니다.
이미지가 제대로 업로드되고 서버가 FileUpload HttpServlet의 doPost 기능으로 리디렉션됩니다. 요청에서 BLOB 키를 읽고 데이터 저장소에 저장할 수 있습니다.
내 문제는 클라이언트에게 응답을 보내는 것입니다. 내가 본 모든 것은 response.sendRedirect 함수를 사용하는 것을 가리키고 있지만, 아직 성공적이지는 못했다.
public class FileUpload extends HttpServlet
{
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
BlobstoreService blobstoreService = BlobstoreServiceFactory.getBlobstoreService();
Map<String, List<BlobKey>> blobs = blobstoreService.getUploads(request);
BlobKey blobKey = blobs.get("picFileUpload").get(0);
ShipHull shipHull = new ShipHull();
shipHull.setShipHullName(request.getParameter("hullNameText"));
shipHull.setShipImageURL("/shipbuilder/blobService?blob-key=" + blobKey.getKeyString());
PersistenceManager pm = PMF.get().getPersistenceManager();
try
{
pm.makePersistent(shipHull);
}
catch (Exception e)
{
String hi = "hello";
}
finally
{
pm.close();
}
Boolean test = response.isCommitted();
response.sendRedirect("/shipbuilder/FileUpload?gwt.codesvr=127.0.0.1:9997&shipHullName=" + shipHull.getShipHullName());
test = response.isCommitted();
return;
}
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException
{
String id = req.getParameter("shipHullName");
resp.setHeader("Content-Type", "text/html");
resp.getWriter().println(id);
}
}
동일한 서블릿에서 클라이언트를 doGet으로 리디렉션하려고합니다. 나는 이것을 시도했지만 gwt.codesvr=127.0.0.1:9997
과 shipHullName=" + shipHull.getShipHullName())
없이 doGet 함수에 도달하지 못했다. 나는 또한 https://www.google.com
을 시도했다.
이것은 모두 개발 서버에서 수행되고 있습니다 (아직 프로덕션 서버에서는 시도하지 않았습니다).
이미지 저장 상태를 반환하는 다른 방법이있는 경우 (파일 이름이 이미 사용 된 것처럼), 다른 것을 시도해도 괜찮습니다.
감사합니다.
당신이 제안에 어떤 행운이 있었나요? – SSR