首页 新闻 会员 周边 捐助

Struts的一个小问题(初学

0
[待解决问题]

开发环境Tomcat9+JDK8,eclipse编写

WEB.XML
```<?xml version="1.0" encoding="UTF-8"?>
<web-app id="starter" version="2.4"
xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<filter>
<filter-name>action2</filter-name>
<filter-class>org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>action2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>

</web-app>
JAVA代码

package com.Struts2;

import com.opensymphony.xwork2.ActionSupport;

public class HelloWorldAction extends ActionSupport {
/**
*
*/
private static final long serialVersionUID = 1L;
private String mes;

public String getMes() {
    return mes;
}

public void setMes(String mes) {
    this.mes = mes;
}

@Override
public String execute() throws Exception {
    // TODO Auto-generated method stub
    mes="HELLO";
    return SUCCESS;
}

}

```
jsp

```<%@ page language="java" contentType="text/html; utf-8"
pageEncoding="utf-8"%>

<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<h1>
HELLO
</h1>

</body>
</html>

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="default" extends="struts-default">
    <action name="Hello" class="com.Struts2.HelloWorldAction">
        <result name="success">index.jsp</result>
    </action>
</package>

</struts>
```

问题补充:

排版有点乱
开发环境食tomcat9+jdk8

码废的主页 码废 | 菜鸟二级 | 园豆:204
提问于:2018-11-28 13:52
< >
分享
所有回答(1)
0

struts的版本问题

码废 | 园豆:204 (菜鸟二级) | 2018-11-29 22:02
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册