struts2 通过action来建立并访问helloworld
来源:互联网 发布:电影大全软件安卓版 编辑:程序博客网 时间:2024/05/08 18:39
1、eclipse中新建一个dynamic web project工程sturts2,将struts2的架包复制到WEB-INF中的lib文件中,架包有:commons-fileupload-1.3.1.jar,commons-io-2.2.jar,commons-lang3-3.1.jar,commons-logging-1.1.3.jar,core-0.6.2.jar,freemarker-2.3.19.jar,javassist-3.11.0.GA.jar,ognl-3.0.6.jar,servlet-api.jar(此包在tomcat里),struts2-core-2.3.16.3.jar,xwork-core-2.3.16.3.jar。
2、在WEB-INF中建立web.xml,内容如下:
<?xml version="1.0" encoding="UTF-8"?><web-app xmlns:xsi="www.w3.org/2001/XMLSchema-instance" xmlns="java.sun.com/xml/ns/javaee" xsi:schemaLocation="java.sun.com/xml/ns/javaee java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0"><!-- <display-name>Struts2</display-name> --><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><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></web-app>
3、在src中建立struts.xml 内容如下:
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" "struts.apache.org/dtds/struts-2.0.dtd"><struts><!-- 配置包,名称为bookcode --><package name="" extends='struts-default' namespace="/test"><!-- 配置Action --><action name="helloworld" class="cn.xs.action.HelloWorldAction" method = "execute"><!-- 配置返回结果 --><result name="success">/WEB-INF/page/hello.jsp</result><result name="error">/error.jsp</result></action></package></struts>
4、在src中建立包cn.xs.action,包中建立HelloWorldAction.java
// ---------------------------------------------------------// @author sheng.xu// @version 1.0.0// @date2014年5月29日// ---------------------------------------------------------package cn.xs.action;/** * @author sheng.xu * */public class HelloWorldAction {public String message;/** * @return the message */public String getMessage() {return message;}/** * @param message the message to set */public void setMessage(String message) {this.message = message;}public String execute(){this.message = "aaaaaa";return "success";}}5、在WEB-INF中建立文件夹page,在page中建立hello.jsp文件内容如下:
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%><!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "www.w3.org/TR/html4/loose.dtd"><html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>Insert title here</title></head><body>${message}</body></html>6、导出war包,放入tomcat的webapp目录中
7、浏览器输入:localhost:8080/Struts2/test/helloworld
0 0
- struts2 通过action来建立并访问helloworld
- 使用struts2 建立Helloworld
- 基于Struts2在jsp中通过href访问Action
- 并发CURL访问并通过REDIS来控制并发数
- struts2异常 no action named HelloWorld .......
- Struts2 Action的访问路径
- Struts2中Action访问ServletAPI
- Struts2 Action的访问路径
- struts2 Action访问Servlet Api
- Struts2--------Action访问Servlet API
- Struts2 Action访问Servlet API
- 【3】Struts2的Action访问
- Struts2-Action访问Servlet API
- Struts2中Action访问ServletAPI
- 通过Action访问Servlet API
- 2、通过helloworld来认识下backbone
- 2、通过helloworld来认识下backbone
- 通过helloworld来认识下backbone
- linux grep命令
- 发快递进口国解困房看家狗空间快热就iruiu
- Java Swing界面编程(22)---事件处理:动作事件及监听处理
- 饭到口国家开发健康风纪扣解放军
- 我的一生
- struts2 通过action来建立并访问helloworld
- iOS开发 - 如何获取设备的总容量和可用容量
- Java Web开发中Sping的总结整合dao.xml,service.xml,action.xml
- 每天一个linux命令(9):touch 命令
- IOS 学习之各种知识链接
- Asm.js: Javascript的编译目标
- iOS开发 - 获取沙盒文件夹大小
- Android中调用js方法及js中调用本地方法
- Linux下的Nano命令