标签:导入 相同 type spl scope space 需要 org namespace
Maven方式:pom.xml配置依赖:
<dependency><groupId>junit</groupId><artifactId>junit</artifactId><version>3.8.1</version><scope>test</scope></dependency><dependency><groupId>org.apache.struts</groupId><artifactId>struts2-core</artifactId><version>2.5.16</version></dependency><dependency><groupId>org.apache.struts.xwork</groupId><artifactId>xwork-core</artifactId><version>2.3.34</version></dependency><dependency><groupId>commons-logging</groupId><artifactId>commons-logging</artifactId><version>1.2</version></dependency>
1).配置Struts2核心配置文件
名称:src下 位置: struts.xml( 固定 )
2).引入dtd约束
<!DOCTYPE struts PUBLIC"-//Apache Software Foundation//DTD Struts Configuration 2.5//EN""http://struts.apache.org/dtds/struts-2.5.dtd">3). 配置Web.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" 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"><display-name>Struct2day1</display-name><welcome-file-list><welcome-file>index.html</welcome-file><welcome-file>index.htm</welcome-file><welcome-file>index.jsp</welcome-file><welcome-file>default.html</welcome-file><welcome-file>default.htm</welcome-file><welcome-file>default.jsp</welcome-file></welcome-file-list><filter><filter-name>struts2</filter-name><filter-class>org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter</filter-class><!-- 低版本对应的class可能有细微差别 --></filter><filter-mapping><filter-name>struts2</filter-name><url-pattern>/*</url-pattern></filter-mapping></web-app>
<package><action><result> </result></action></package>
访问action有三种方式
<action name="hello" class = "per.wzy.Action.Hello" method="add"><!-- 配置方法的返回值到不同的页面 --><!-- <result name ="ok">/Hello.jsp</result>--></action>
<struts><package name="" extends="struts-default" strict-method-invocation="false"><action name="stu_*" class="per.wzy.Action.Hello" method="{1}"><allowed-methods></allowed-methods></action></package></struts>
<wiz_tmp_tag id="wiz-table-range-border" contenteditable="false" style="display: none;">
标签:导入 相同 type spl scope space 需要 org namespace
原文地址:https://www.cnblogs.com/local-wzy/p/11229571.html