论坛首页 Java企业应用论坛

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

浏览 2604 次
精华帖 (12) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
作者 正文
   发表时间:2009-11-16  
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
   发表时间:2009-12-02  
呵呵,我也遇到过相同的问题。
特别是第二个,一度准备放弃使用Spring的标签。后来发现使用common-Validator验证框架的时候,取错误信息相当麻烦,不得不使用标签。
0 请登录后投票
   发表时间:2009-12-02  
第二个问题最好就是把Long,Date.....这些类型都注册一遍,不然有的忙。
0 请登录后投票
论坛首页 Java企业应用版

跳转论坛:
Global site tag (gtag.js) - Google Analytics