web.xml配置内容
<?xml version="1.0" encoding="UTF-8"?> <web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"> <display-name>clickdemo</display-name> <servlet> <servlet-name>ClickServlet</servlet-name> <servlet-class>org.apache.click.ClickServlet</servlet-class> <load-on-startup>0</load-on-startup> </servlet> <servlet-mapping> <servlet-name>ClickServlet</servlet-name> <url-pattern>*.html</url-pattern> </servlet-mapping> <welcome-file-list> <welcome-file>welcome.html</welcome-file> </welcome-file-list> </web-app>
click。xml配置
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE click-app PUBLIC "-//Apache Software Foundation//DTD Click Configuration 2.2//EN" "http://click.apache.org/dtds/click-2.2.dtd"> <click-app> <pages package="cn.elve.click.page" automapping="false"> <page classname="InputPage" path="/input.html"></page> <page classname="SayHelloPage" path="/sayHello.html"></page> <page classname="WelcomePage" path="/welcome.html"></page> </pages> <mode value="debug"/> </click-app>java代码
1.WelcomePage
package cn.elve.click.page; import java.util.Date; import org.apache.click.Page; public class WelcomePage extends Page { protected String theMessage = "welcome!"; public Date date = new Date(); public WelcomePage() { addModel("message", theMessage); addModel("time", date); } }
2.SayHelloPage
package cn.elve.click.page; import org.apache.click.Page; public class SayHelloPage extends Page { private String name; public void onInit(){ super.onInit(); if(name != null){ addModel("name", name); } } public String getName() { return name; } public void setName(String name) { this.name = name; } }
3.InputPage
package cn.elve.click.page; import org.apache.click.Page; import org.apache.click.control.Form; import org.apache.click.control.Submit; import org.apache.click.control.TextField; public class InputPage extends Page { public Form form = new Form(); private TextField nameField; public InputPage() { form.setLabelsPosition(Form.POSITION_TOP); nameField = new TextField("Enter your name"); form.add(nameField); form.add(new Submit("Submit",this,"onSubmitClick")); } public boolean onSubmitClick(){ SayHelloPage nextPage = getContext().createPage("/sayhello.html"); nextPage.setName(nameField.getValue()); setForward(nextPage); return false; } }
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>welcome.html</title> </head> <body> <p>$message</p> <p>$time</p> </body> </html>基本就这样。启动内容如下
[Click] [info ] *** Initializing Click 2.3.0 in debug mode *** [Click] [info ] initialized LogService: org.apache.click.service.ConsoleLogService [Click] [debug] listing classes in jar:file:/D:/Tomcat/apache-tomcat-7.0.47/webapps/click/WEB-INF/lib/click-2.3.0.jar!/META-INF/resources [Click] [info ] found jar: file:/D:/Tomcat/apache-tomcat-7.0.47/webapps/click/WEB-INF/lib/click-2.3.0.jar [Click] [debug] listing classes in jar:file:/D:/Tomcat/apache-tomcat-7.0.47/webapps/click/WEB-INF/lib/click-extras-2.3.0.jar!/META-INF/resources [Click] [info ] found jar: file:/D:/Tomcat/apache-tomcat-7.0.47/webapps/click/WEB-INF/lib/click-extras-2.3.0.jar [Click] [debug] listing classes in jar:file:/D:/Tomcat/apache-tomcat-7.0.47/webapps/click/WEB-INF/lib/click-nodeps-2.3.0.jar!/META-INF/resources [Click] [info ] found jar: file:/D:/Tomcat/apache-tomcat-7.0.47/webapps/click/WEB-INF/lib/click-nodeps-2.3.0.jar [Click] [debug] listing classes in jar:file:/D:/Tomcat/apache-tomcat-7.0.47/webapps/click/WEB-INF/lib/jsf-impl.jar!/META-INF/resources [Click] [info ] found jar: file:/D:/Tomcat/apache-tomcat-7.0.47/webapps/click/WEB-INF/lib/jsf-impl.jar [Click] [debug] click.xml pages: [Click] [debug] /input.html -> cn.elve.click.page.InputPage [Click] [debug] /sayHello.html -> cn.elve.click.page.SayHelloPage [Click] [debug] /welcome.html -> cn.elve.click.page.WelcomePage [Click] [debug] initializing FileLoadService: org.apache.click.service.CommonsFileUploadService [Click] [debug] initializing TemplateService: org.apache.click.service.VelocityTemplateService [Click] [debug] initializing ResourceService: org.apache.click.service.ClickResourceService [Click] [debug] initializing MessagesMapService: org.apache.click.service.DefaultMessagesMapService [Click] [info ] Click 2.3.0 initialized in debug mode页面运行却不正常
求大神解决
http://www.ibm.com/developerworks/cn/web/wa-apacheclick/
这个是官方的demo。基本一样。除了click.xml配置有点区别。也不是那个问题。
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。