http://groups.google.com/group/google-appengine-java/browse_thread/thread/1e3868a6a2661585首先参考这篇文章,修改一下sitemesh中的Factory.class。然后将修改后的包加入到gae项目中就可以啦。
下面是我的配置文件
web.xml文件,注意红色部门直接写“*”, 不用加"/"
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<filter>
<filter-name>sitemesh</filter-name>
<filter-class>com.opensymphony.module.sitemesh.filter.PageFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>sitemesh</filter-name>
<url-pattern>*</url-pattern>
</filter-mapping>
<servlet>
<servlet-name>dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>dispatcher</servlet-name>
<url-pattern>*.htm</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
接下来在WEB-INF/下面新建一个decorators文件加,里面写个main.jsp
decorators.xml文件 注意红色字体,路径要写正确
<decorators defaultdir="/WEB-INF/decorators">
<decorator name="main" page="main.jsp">
<pattern>/*</pattern>
</decorator>
</decorators>
main.jsp 文件,很简单。
<%@page pageEncoding="UTF-8" contentType="text/html; charset=UTF-8"%>
<%@ taglib uri="http://www.opensymphony.com/sitemesh/decorator"
prefix="decorator"%>
<%@ taglib uri="http://www.opensymphony.com/sitemesh/page" prefix="page"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title><decorator:title default="这里随便放什么都行" />main</title>
<decorator:head />
</head>
<body>
纵贯线北京演唱会
<hr>
<decorator:body />
<hr>
没有票真可惜
</body>
</html>
sitemesh.xml文件
<sitemesh> <page-parsers> <parser default="true" class="com.opensymphony.module.sitemesh.parser.DefaultPageParser" /> <parser content-type="text/html" class="com.opensymphony.module.sitemesh.parser.FastPageParser" /> <parser content-type="text/html;charset=UTF-8" class="com.opensymphony.module.sitemesh.parser.FastPageParser" /> </page-parsers> <decorator-mappers> <mapper class="com.opensymphony.module.sitemesh.mapper.ConfigDecoratorMapper"> <param name="config" value="/WEB-INF/decorators.xml" /> </mapper> </decorator-mappers> </sitemesh>
补充两个;
1 中文页面上传乱码问题可以参考这篇文章
http://www.jxva.com/blog/personal-diary/change-the-google-app-engine's-javac-compiler-encoding.html
上面无法访问的也可以看这个javaeye网友转载http://struts.iteye.com/blog/367952
2 上传出错问题,根据我这几天上传出错的经验 下面这个错误90%以上是jsp页面错误引起的
!MESSAGE Unable to upload app: Failed to compile java files. See the Eclipse error log for more details !STACK 0 com.google.appengine.tools.admin.AdminException: Unable to upload app: Failed to compile java files. at com.google.appengine.tools.admin.AppAdminImpl.update(AppAdminImpl.java:47) at com.google.appengine.eclipse.core.proxy.AppEngineBridgeImpl.deploy(AppEngineBridgeImpl.java:203) at com.google.appengine.eclipse.core.deploy.DeployProjectJob.runInWorkspace(DeployProjectJob.java:97) at org.eclipse.core.internal.resources.InternalWorkspaceJob.run(InternalWorkspaceJob.java:38) at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55) Caused by: java.lang.RuntimeException: Failed to compile java files. at com.google.appengine.tools.admin.Application.compileJavaFiles(Application.java:363) at com.google.appengine.tools.admin.Application.compileJsps(Application.java:326) at com.google.appengine.tools.admin.Application.createStagingDirectory(Application.java:235) at com.google.appengine.tools.admin.AppAdminImpl.update(AppAdminImpl.java:39) ... 4 more
ps 今天特地学习的sitemesh,网上一搜,99%的中文文章都是重复的,天下文章一大抄啊。