请求的资源[/Strutsdemo/]不可用

救救孩子吧,快疯了

tomcat7.0.105

struts2.2.3.1

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/j2ee”
xmlns:web=”http://xmlns.jcp.org/xml/ns/javaee” xsi:schemaLocation=”http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd http://xmlns.jcp.org/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd” version=”2.4″>
<filter>
<!– Filter名称 –>
<filter-name>struts2</filter-name>
<!–Filter入口 –>
<filter-class>org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
<filter-mapping>
<!– Filter名称 –>
<filter-name>struts2</filter-name>
<!– 截获的所有URL–>
<url-pattern>/*</url-pattern>
</filter-mapping>
<welcome-file-list>
<!– 开始页面 –>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>

struts.xml

<?xml version=”1.0″ encoding=”UTF-8″?>

<!DOCTYPE struts PUBLIC
“-//Apache Software Foundation//DTD Struts Congfiguration 2.0//EN”
“http://struts.apache.org/dtds/struts-2.0.dtd”>

<!–指定struts.xml文件的根元素–>
<struts>
<!–配置包,包名为default,
该包继承了Struts 2框架的默认包struts-default–>
<package name=”default” namespace=”/” extends=”struts-default”>
<!–定义名为hello的Action,该Action的处理类为com.action.TestAction,
并映射到success.jsp页面–>
<action name=”hello” class=”com.action.TestAction”>
<result>/success.jsp</result>
</action>
</package>
</struts>

struts.propertoes

<struts.i18n.encoding value=”UTF-8″/>

index.jsp

<%@ page language=”java” contentType=”text/html; charset=UTF-8″
pageEncoding=”UTF-8″%>
<%@ taglib prefix=”s” uri=”/struts-tags” %>

<!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= “>
<title>Insert title here</title>
</head>
<body>
<!–a标签–>
<s:a action=”hello”>hello</s:a>

</body>
</html>

success.jsp

<%@ page language=”java” contentType=”text/html; charset=UTF-8″
pageEncoding=”UTF-8″%>
<%@ taglib prefix=”s” uri=”/struts-tags” %>

<!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>Insert title here</title>
</head>
<body>
<body>
<!–输出helo值–>
<s:property value=”helo”/>
</body>

</body>
</html>

TestAction.java

package com.action;

import com.opensymphony.xwork2.ActionSupport;

public class TestAction extends ActionSupport{
private static final long serialVersionUID=1L;
private String helo; //Action属性
//getter方法
public String getHelo() {
return helo;
}
//setter方法
public void setHelo(String helo) {
this.helo = helo;
}
//重载execute()方法
public String execute() throws Exception {
helo=”hello,world”;
return SUCCESS;
}
}

原文链接:https://blog.csdn.net/laobpds/article/details/108720025?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522165277103516781683929162%2522%252C%2522scm%2522%253A%252220140713.130102334.pc%255Fblog.%2522%257D&request_id=165277103516781683929162&biz_id=0&utm_medium=distribute.pc_search_result.none-task-blog-2~blog~first_rank_ecpm_v1~times_rank-2-108720025-null-null.nonecase&utm_term=%E8%B5%84%E6%BA%90

© 版权声明
THE END
喜欢就支持一下吧
点赞0 分享
评论 抢沙发
头像
文明发言,共建和谐米科社区
提交
头像

昵称

取消
昵称表情图片