Maven + Spring + Hibernate + Struts2 整合第四部分

现在我们编写struts的配置文件:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<constant name="struts.enable.DynamicMethodInvocation" value="true" />
<constant name="struts.devMode" value="true" />
<constant name="strtus.objectFactory" value="spring" />
<package name="localhost.login" extends="struts-default">
<action name="SignIn_input" class="userLoginAction">
<result>/hello.jsp</result>
<result name="input">/user/login.jsp</result>
</action>
</package>
</struts>

现在我们编写一下前台的几个简单页面,欢迎页面。

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<META HTTP-EQUIV="Refresh" CONTENT="0;URL=SignIn_input.action">
</head>
<body>
<p>Loading ...</p>
</body>
</html>


编写login.jsp文件:

%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Log in</title>
</head>
<body>
<s:form action="SignIn_input" validate="true">
<s:textfield label="User Name" name="user.name" required="true" />
<s:password label="Password" name="user.password" required="true" />
<s:iterator value="errors">
<s:property />
</s:iterator>
<s:submit value="Login" />
</s:form>
</body>
</html>

最后编写登陆后的文件:

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01
Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Hello</title>
</head>
<body>
<s:if test="#session.user!=null">
<h2>Hello <s:property value="#session.user.name"/></h2>
</s:if>
</body>
</html>

先写到这里吧。。。。。。。。。。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值