struts实现登陆界面

1.login.jsp页面:

<%@ page language="java" contentType="text/html; charset=gb2312"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<html>
<head>
<style type="text/css">
#table1{
border-collapse: collapse;
border-bottom-color: #000FF;
}
</style>
<title>struts用户登录</title>
</head>
<body>
<br><br><br>
<div align="center">
<s:form method="post" action="Login" theme="simple">
<table id="table1" border="1" cellpadding="0" cellspacing="0" width="300" >
<tr>
<td width="100%" bgcolor="#C0C0C0" align="center">
<font color="#0000FC">用户登录</font>
</td>
</tr>
<tr>
<td align="left">
<s:fielderror/><s:property value="errormsg"/>
</td>
</tr>
<tr>
<td >
请输入用户名:<s:textfield name="adminusername"/><br>
请输入密码:<s:password name="adminuserpassword"/><br>  
<s:submit value="提交"/>
<s:hidden name="action" value="login"/>
</td>
</tr>
</table>

</s:form>

</div>
</body>
</html>

2.struts.xml页面:

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
	"-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
	"http://struts.apache.org/dtds/struts-2.3.dtd">

<struts>

    <constant name="struts.enable.DynamicMethodInvocation" value="false" />
    <constant name="struts.devMode" value="true" /> 

    <package name="default"  extends="struts-default">

        <default-action-ref name="index" />

        <global-results>
            <result name="error">/error.jsp</result>
        </global-results>

        <global-exception-mappings>
            <exception-mapping exception="java.lang.Exception" result="error"/>
        </global-exception-mappings>
 
        
        <action name="Login" class="com.action.LoginAction">
        <result>/index.jsp</result>
        <result name="input">login.jsp</result>

        </action>
        
       
    </package>

 
    <!-- Add packages here -->

</struts>

3.数据校验配置文件:LoginAction-validation.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE validators PUBLIC "-//Apache Struts//XWork Validator 1.0.2//EN"   
  "http://struts.apache.org/dtds/xwork-validator-1.0.2.dtd">
  <validators>
  <field name="adminusername">
  <field-validator type="requiredstring">
  <param name="trim">true</param>
  <message>需要输入用户名</message>
  </field-validator>
  </field>
  
  <field name="adminuserpassword">
  <field-validator type="requiredstring">
  <param name="trim">true</param>
  <message>需要输入密码</message>
  </field-validator>
  </field>
  </validators>

4.struts.properties文件内容:

struts.locale=zh_CN
struts。i18n.encoding=GBK
 
 
 
 

转自:@struts登陆界面配置详细文件清单


struts实现登陆界面_第1张图片


你可能感兴趣的:(java,eclipse,struts,utf-8,界面)