freemark的例子操作
对freemark理解与例子
?
? 首先将 struts-tags.tld 放在WEB-INF 目录下
?
?1.login.ftl
?
?
?
2.success.ftl
?
?
5.struts.xml
?
?
6.action
?
package com.yihaodian.action;import com.opensymphony.xwork2.ActionSupport;public class LoginAction extends ActionSupport {private static final long serialVersionUID = 1L;private String username;private String password; private String error;public String getUsername() {return username;}public void setUsername(String username) {this.username = username;}public String getPassword() {return password;}public void setPassword(String password) {this.password = password;}public String getError() {return error;}public void setError(String error) {this.error = error;}public String execute(){if(getUsername().equals("zhaoyun")&&getPassword().equals("123")){return "success";}else{setError("登陆失败!");return "error";}} }?
?
7.访问
?
http://localhost:8080/FreeMarkDemo/Login
?