struts环境搭建

来源:互联网 发布:手机棋牌游戏辅助软件 编辑:程序博客网 时间:2024/05/22 05:11

时下最流行的SSH框架,会的人很多,但是也有很多人却不会用eclipse搭建struts框架,我搭建一个DEMO备用。


Struts框架主要是在Web.xml配置一个filter,XML文件如下

<?xml version="1.0" encoding="utf-8"?><web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0"><!-- 定义Struts2的核心filter --><filter><filter-name>struts2</filter-name><filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class></filter><filter-mapping><filter-name>struts2</filter-name><url-pattern>/*</url-pattern></filter-mapping></web-app>

再加一个Struts.xml文件

<?xml version="1.0" encoding="utf-8" ?><!DOCTYPE struts PUBLIC"-//Apache Software Foundation//DTD Struts Configuration 2.1.7//EN""http://struts.apache.org/dtds/struts-2.1.7.dtd"><struts><constant name="struts.custom.i18n.resources" value="xiaoice"></constant><constant name="struts.i18n.encoding" value="utf-8"></constant><package name="struts-main" extends="struts-default"><action name="login" class="org.jspjs.main.action.LoginAction"><result name="input">/login.jsp</result><result name="error">/error.jsp</result><result name="success">/success.jsp</result></action></package></struts>

主要配置就这2个了,很简单的。


DEMO下载地址:

http://download.csdn.net/detail/xiaocie3456/5281936

原创粉丝点击