2009-09-20 95 views
0

我在Google Appengine中的会话在开发环境中工作,但在部署时没有。Google AppEngine中的春季会话表单

我在appengine-web.xml中将会话启用设置为true。

我在这里错过了什么吗?我必须重写控制器中的initBinder,因为它在appengine中工作,因为Spring试图“访问系统类加载器”

也许我也应该为我的问题做点事,但我不知道它是什么。

我的控制器:

package com.springtutorial.controller; 


import javax.servlet.http.HttpServletRequest; 
import javax.servlet.http.HttpServletResponse; 

import org.springframework.beans.propertyeditors.StringTrimmerEditor; 
import org.springframework.validation.BindException; 
import org.springframework.web.bind.ServletRequestDataBinder; 
import org.springframework.web.servlet.ModelAndView; 
import org.springframework.web.servlet.mvc.SimpleFormController; 

import com.springtutorial.model.Course; 

public class GetCourseController extends SimpleFormController { 

    private static final String ADD_VIDEO_TO_CURRENT_LEARNING_ACTIVITY = "video"; 
    private static final String NEW_REQUEST = ""; 
    private static final String ADD_LEARNING_ACTIVITY = "add learning activity"; 
    private String currentRequest; 
    private int activityNumber; 

    GetCourseController(){ 
     setCommandClass(Course.class); 
     setCommandName("course"); 
     setSessionForm(true); 
    } 

    @Override 
    protected ModelAndView showForm(HttpServletRequest request, 
      HttpServletResponse response, BindException errors) 
      throws Exception { 
     if (ADD_LEARNING_ACTIVITY.equals(currentRequest)){ 
      request.setAttribute("request","add learning activity"); 
      request.setAttribute("activityNumber",activityNumber); 
      activityNumber++; 
     } else if (ADD_VIDEO_TO_CURRENT_LEARNING_ACTIVITY.equals(currentRequest)){ 

     } 
     else { 
      request.setAttribute("request","new"); 
     } 
     return super.showForm(request, response, errors); 
    } 
    @Override 
    protected boolean isFormChangeRequest(HttpServletRequest request) { 
     String action = request.getParameter("submit"); 
     if (ADD_LEARNING_ACTIVITY.equals(action)){ 
      currentRequest = ADD_LEARNING_ACTIVITY; 
      return true; 
     } 
     return false; 
    } 
    @Override 
    protected ModelAndView onSubmit(HttpServletRequest request, 
      HttpServletResponse response, Object command, BindException errors) 
      throws Exception { 
     currentRequest=NEW_REQUEST; 
     return super.onSubmit(request, response, command, errors); 
    } 
    @Override 
    protected void initBinder(HttpServletRequest request, 
      ServletRequestDataBinder binder) throws Exception { 
     binder.registerCustomEditor(String.class, new StringTrimmerEditor(false)); 
    } 

回答

0

我得到这个通过实现我所有的命令类序列化的工作。我检查了日志,并得到了NotSerializableException。

+0

不知道为什么这是downvoted,这是相当宝贵的(我有同样的问题)。 – Joris 2012-02-06 05:15:26