在google appengine中使用Spring mvc 3.0中遇到的问题

1. 在使用jstl时不需要导入jstl,jsp 和servlet的包,而且需要在jsp的头部加上isElIgnored这个参数
引用
<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>


2.使用spring的form tag时会报“org.springframework.web.servlet.tags.RequestContextAwareTag doStartTag: access denied (java.lang.RuntimePermission getClassLoader)”的错误。解决的办法是加入以下代码到你的controller中

@Override
protected void initBinder(HttpServletRequest request,
ServletRequestDataBinder binder) throws Exception {
binder.registerCustomEditor(String.class,
new StringTrimmerEditor(false));
}


你也可以使用全局性的注册:加入下面代码到spring xml中

引用
<bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
<property name="webBindingInitializer">
<bean class="com.xtremeprog.iphone.web.AppBindingInitializer"/>
</property>
</bean>


AppBindingInitializer.java
package com.xtremeprog.iphone.web;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.propertyeditors.CustomDateEditor;
import org.springframework.beans.propertyeditors.StringTrimmerEditor;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.support.WebBindingInitializer;
import org.springframework.web.context.request.WebRequest;

import java.text.SimpleDateFormat;
import java.util.Date;


public class AppBindingInitializer  implements WebBindingInitializer {

	public void initBinder(WebDataBinder binder, WebRequest request) {
		binder.registerCustomEditor(String.class, new StringTrimmerEditor(false));
	}
}



Reference: http://www.cancunmods.com/principal/content/how-use-spring-tags-google-app-engine

你可能感兴趣的:(java,spring,Web,mvc,Google)