标签:code pen dep ref ack ring text pack 名称
pom.xml
<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>thir_d</groupId> <artifactId>thir_d</artifactId> <version>1.0-SNAPSHOT</version> <dependencies> <dependency> <groupId>org.apache.struts</groupId> <artifactId>struts2-core</artifactId> <version>2.5.14.1</version> </dependency> </dependencies> </project>
helloaction.java
package com; public class helloaction { //访问action,每次访问action时,默认执行名称execute方法 public String execute(){ return "ok"; } }
struts.xml
<?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="hellodemo" extends="struts-default" namespace="/"> <!--name="访问名称" --> <action name="hello" class="com.helloaction"> <!--配置方法的返回值--> <result name="ok">/index.jsp</result> </action> </package> </struts>
index.jsp
<%@ page contentType="text/html;charset=UTF-8" language="java" %> <html> <head> <title>$Title$</title> </head> <body> $END$ <a href="hello.jsp">点击前往测试页面</a> </body> </html>
hello.jsp
<%@ page contentType="text/html;charset=UTF-8" language="java" %> <html> <head> <title>$Title$</title> </head> <body> Hello World </body> </html>
测试结果:
标签:code pen dep ref ack ring text pack 名称
原文地址:https://www.cnblogs.com/zuiaimiusi/p/11920537.html