开发者社区> 问答> 正文

Apache Click框架入门问题click.xml配置与页面显示问题 :报错

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
页面运行却不正常

求大神解决







展开
收起
kun坤 2020-06-14 07:08:29 652 0
1 条回答
写回答
取消 提交回答
  • http://www.ibm.com/developerworks/cn/web/wa-apacheclick/

    这个是官方的demo。基本一样。除了click.xml配置有点区别。也不是那个问题。


    2020-06-14 07:08:38
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
Apache Flink技术进阶 立即下载
Apache Spark: Cloud and On-Prem 立即下载
Hybrid Cloud and Apache Spark 立即下载

相关镜像