博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
FORM验证简单demo
阅读量:7113 次
发布时间:2019-06-28

本文共 7413 字,大约阅读时间需要 24 分钟。

详解稍后加入。

        项目结构如图:

      

              web.xml

            

com.alibaba.citrus.logconfig.LogConfiguratorListener
com.alibaba.citrus.webx.context.WebxContextLoaderListener
mdc
com.alibaba.citrus.webx.servlet.SetLoggingContextFilter
webx
com.alibaba.citrus.webx.servlet.WebxFrameworkFilter
excludes
passthru
mdc
/*
webx
/*
webx.xml

common
${productionMode:true}
webx-app1.xml

app1
default.xml

#showHead ("My Simple Webx Application")

This is default

$screen_placeholder

[Home] [Dev Home]

hello.vm

$page.setTitle("Hello, $name")

Hello, $name!

index.vm

$csrfToken.hiddenField

Hello, what's your name?

#set($groupB = $form.simple.defaultInstance)
login.vm

$page.setTitle("Hello, $name")

${name} is not valid

form.xml

提交的数据已过期
必须填写 ${displayName}
必须填写 ${displayName}
simpleAction.java

/* * Copyright 2010 Alibaba Group Holding Limited. * All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * *    http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */package com.alibaba.webx.tutorial1.app1.module.action;import java.util.List;import com.alibaba.citrus.turbine.Context;import com.alibaba.citrus.turbine.Navigator;import com.alibaba.citrus.turbine.dataresolver.FormGroup;import com.alibaba.webx.tutorial1.app1.SimpleObject;public class SimpleAction {    public void doGreeting(@FormGroup("simple") SimpleObject simple, Navigator nav) throws Exception {             String name = simple.getName();        String password=simple.getPassword();               if("LTianchao".equals(name)&&("123".equals(password))){        	nav.redirectTo("app1Link").withTarget("hello").withParameter("name", name);        	        }        else       	nav.redirectTo("app1Link").withTarget("login").withParameter("name", name);        System.out.println("action begin");    	System.out.println("done");    	    	//、、context.put("name",simple[1].getName());    	    }}
hello.java

/* * Copyright 2010 Alibaba Group Holding Limited. * All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * *    http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */package com.alibaba.webx.tutorial1.app1.module.screen;import com.alibaba.citrus.turbine.Context;import com.alibaba.citrus.turbine.dataresolver.Param;public class Hello {    public void execute(@Param("name") String name, Context context) {        context.put("name", name);    }}
login.java
/* * Copyright 2010 Alibaba Group Holding Limited. * All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * *    http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */package com.alibaba.webx.tutorial1.app1.module.screen;import com.alibaba.citrus.turbine.Context;import com.alibaba.citrus.turbine.dataresolver.Param;public class login {    public void execute(@Param("name") String name, Context context) {        context.put("name", name);    }}
SimleObject.java

/* * Copyright 2010 Alibaba Group Holding Limited. * All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * *    http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */package com.alibaba.webx.tutorial1.app1;public class SimpleObject {    private String name;    private String password;            public String getName() {        return name;    }    public void setName(String name) {        this.name = name;    }    public String getPassword() {        return password;    }    public void setPassword(String password) {        this.password = password;    }  }
你可能感兴趣的文章
Webpack4 学习笔记 - 01:webpack的安装和简单配置
查看>>
二)golang工厂模式
查看>>
React 教程:快速上手指南
查看>>
Python 的 heapq 模块源码分析
查看>>
Jitsi快捷安装
查看>>
区块链技术的基本特点
查看>>
阿里云容器服务DaemonSet实践
查看>>
一个游戏拨账系统的数据库结算设计
查看>>
Kafka Network层解析
查看>>
css加载会造成阻塞吗?
查看>>
聊聊storm TridentWindowManager的pendingTriggers
查看>>
React 解决fetch跨域请求时session失效
查看>>
翻译_只需20行代码创造JavaScript模板引擎(二)
查看>>
Blockchain和Tangle哪一个是未来?
查看>>
apicloud拉起小程序并传递参数
查看>>
虚拟机Centos6.8安装MYSQL5.7,本地Navicat连接
查看>>
简单聊聊DOM
查看>>
【JavaScript】JavaScript Array 对象(数组)
查看>>
github 上有趣又实用的前端项目(持续更新,欢迎补充)
查看>>
opencv python 直方图均衡化
查看>>