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

本文介绍了在使用Spring的form tag时遇到的错误及其解决办法。通过在Controller中注册StringTrimmerEditor或在Spring配置文件中进行全局注册,可以有效避免出现权限拒绝的问题。
1. 在使用jstl时不需要导入jstl,jsp 和servlet的包,而且需要在jsp的头部加上isElIgnored这个参数[quote]<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>[/quote]。

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中

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

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:[url]http://www.cancunmods.com/principal/content/how-use-spring-tags-google-app-engine[/url]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值