<!-- login.jsp -->
<%@ page language="java" page contetType="text/html" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<head>
<!-- 使用text标签输出国际化消息-->
<title><s:text name="title.login"/></title>
</head>
<body>
<s:form action="checkLogin" method="post">
<!-- 表单元素的key值于资源文件的key对应 -->
<s:textfield name="name" key="lebel.username size="20"/>
<s:password name="password" key="lebel.username size="22"/>
<s:submit key="item.submit"/>
</s:form>
</body>
</html>
<!-- loginSuccess.jsp -->
<%@ page language="java" page contetType="text/html" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<html>
<!-- 使用text标签输出国际化消息-->
<head> <title><s:text name="message.success"/></title></head>
<body>
<hr>
<s:text name="ebel.username"/>:<s:property value="name"/>
<s:text name="ebel.password"/>:<s:property value="password"/>
</body>
</html>
//LoginAction.java
package loginAction;
import com.opensymphony.xwork1.ActionContext;
import com.opensymphony.xwork2.ActionContext;
public class LoginAction extends ActionSupport{
private String name;
private String password;
private String tip;
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;
}
public String getTip() {
return tip;
}
public void setTip(String tip) {
this.tip = tip;
}
public String exetute()throws Exception{
if(getName().equals("QQ")&&getPassword().equals("123"))
{
ActionContext.getContext().getSession.put("name",getName());
return "success";
}
else
{return "error";}
}
}
<struts>
<constant name="struts.custom.il8n.resources"value="globalMessage"/>
<contant name="struts.il8n.encoding"value="UTF-8"/>
<package name="I18N" extends="struts-default"namespase="/" exetends="struts-default">
<action name="checkLogin" calss="loginAction.LoginAction">
<result name="success">/I18N/loginSuccess.jsp</result>
<result name="error">/I18N/login.jsp</result>
</struts>