maven struts
来源:互联网 发布:油画淘宝详情页模版 编辑:程序博客网 时间:2024/06/06 01:36
1.maven创建web项目Artifact Id 为项目名称
2.pom.xml添加stryts http://mvnrepository.com/artifact/org.apache.struts/struts2-core
3.web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
id="WebApp_ID" version="3.1">
<display-name>HelloWorld</display-name>
<!-- <init-param>
<param-name>config</param-name>
<param-value>../../resources/struts.xml</param-value>
</init-param> -->
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<!-- 配置核心拦截器 -->
<filter>
<!-- Filter的名字 -->
<filter-name>struts2</filter-name>
<!-- Filter的实现类 struts2.5以前dispatcher.filter---dispatcher.ng.filter. -->
<filter-class>org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<!-- 拦截所有的url -->
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>
4.struts.xml 位置在src.main.resource
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.5//EN"
"http://struts.apache.org/dtds/struts-2.5.dtd">
<struts>
<package name="default" namespace="/" extends="struts-default">
<!-- name:action的名字,访问时使用 http://localhost:8080/项目名/helloworld访问,class:实现类 -->
<action name="helloworld" class="com.st.HelloWorldAction">
<!-- 结果集,即action中SUCCESS返回的视图 -->
<result>
/result.jsp
</result>
</action>
</package>
</struts>
5.HelloWorldAction.java src文件夹右键new - source folder 新建src.main.java(有就不用了)
src.main.java下新建package: com.st calss: HelloWorldAction
HelloWorldAction.java内容:
package com.st;
import com.opensymphony.xwork2.ActionSupport;
public class HelloWorldAction extends ActionSupport {
@Override
public String execute() throws Exception {
System.out.println("Action启动");
return SUCCESS;
}
}
6.result.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Action Result</title>
</head>
<body>
<h1>struts2 is ok</h1>
</body>
</html>
结构:
- maven struts
- Struts 2 Maven Archetypes
- Struts的Maven配置
- Spring+Struts+Hibernate+Maven
- maven创建struts项目
- struts spring mybatis maven随记
- eclipse maven 创建struts项目
- struts-入门 登陆 maven 构建
- SSH学习3:maven Struts Hello World
- eclipse-整合struts和spring-maven
- Maven-创建Web工程,引入struts
- maven建struts项目的问题
- 升级Maven工程的Struts依赖
- 1.Maven 搭建Struts、spring、mybatis框架-安装Maven环境
- Maven整合Jboss spring ibatis 及struts小记
- 用maven整合struts+spring+hibernate之四 添加事务管理
- myeclipse+maven实现多模块项目struts+spring+mybatis,详解
- myeclipse+maven实现多模块项目struts+spring+mybatis,详解
- css 垂直居中
- Linq切勿使用count()>0来判断集合是否为空
- 基于Lock对象的Condition接口实现的有界队列
- 14. Longest Common Prefix(最长公共前缀) —— Java
- butterknife注解框架源码解析
- maven struts
- Shell脚本笔记
- 【NoSql】之Hbase
- 回文数问题
- 手机淘宝app这是怎么了,这是什么bug,还真没有见过。
- 遇到一个全新的需求项目,怎么办?
- input框中的文字加下划线
- Hive创建表
- LeetCode-75. Sort Colors