struts2新手入门被最简单的高懵了 各大侠帮忙!直接代码!//web.xml文件
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<display-name></display-name>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<filter>
<filter-name>struts2</filter-name>
<!-- 控制器 -->
<filter-class>
org.apache.struts2.dispatcher.FilterDispatcher
</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<!-- 任何请求均有过滤器 -->
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>
//struts.xml文件
<?xml version="1.0" encoding="UTF-8"?>
<xml-body>
<struts>
<package name="Helloword" namespace="/" extends="struts-default">
<action name="Helloword" class="mypackage.Helloword">
<result >/WebRoot/helloJsp.jsp</result>
</action>
</package>
</struts>
</xml-body>//MyloginJsp.jsp 主要的页面
<%@ page language="java" import="java.util.*" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%@ page contentType="text/html;charset=utf-8" %><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'MyloginJsp.jsp' starting page</title>
</head>
<body>
This is my JSP page. <br>
<form action="Helloword.action" method="post" >
<table align="center">
<tr><td><input type="text" name="name" /></td></tr>
<tr><td><input type="submit" value="submit"/> </td></tr>
</table>
</form>
</body>
</html>各个文件的层次结构
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<display-name></display-name>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<filter>
<filter-name>struts2</filter-name>
<!-- 控制器 -->
<filter-class>
org.apache.struts2.dispatcher.FilterDispatcher
</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<!-- 任何请求均有过滤器 -->
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>
//struts.xml文件
<?xml version="1.0" encoding="UTF-8"?>
<xml-body>
<struts>
<package name="Helloword" namespace="/" extends="struts-default">
<action name="Helloword" class="mypackage.Helloword">
<result >/WebRoot/helloJsp.jsp</result>
</action>
</package>
</struts>
</xml-body>//MyloginJsp.jsp 主要的页面
<%@ page language="java" import="java.util.*" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%@ page contentType="text/html;charset=utf-8" %><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'MyloginJsp.jsp' starting page</title>
</head>
<body>
This is my JSP page. <br>
<form action="Helloword.action" method="post" >
<table align="center">
<tr><td><input type="text" name="name" /></td></tr>
<tr><td><input type="submit" value="submit"/> </td></tr>
</table>
</form>
</body>
</html>各个文件的层次结构
解决方案 »
- ibatis some properties were not set
- linux下 ssh 修改ftp ip地址
- 关于项目框架
- NoSuchMethodError错误,很急。
- 正在学习spring + struts2 + hibernate/ibatis,希望大家给些学习的方法
- dos下执行javac成功,但执行java时不成功
- 我想在JSP页中显示存储在ORACLE数据库中的图片,500分!
- taglib教程下载,学习编写自定义标签的好资料
- 请问Eclipse3.0+tomcat5 如何配置?
- Struts1.10与weblogic6.0整合问题
- com.microsoft.sqlserver.jdbc.SQLServerException: '=' 附近有语法错误。
- 怎么把程序最小化到托盘
Thestruts2
src
mypackage
Helloword.java
struts.xml
WebRoot
WEB-INF
web.xml
MyloginJsp.jsp
helloJsp.jsp
Thestruts2
src
--mypackage
----Helloword.java
--struts.xml
WebRoot
--WEB-INF
----web.xml
--MyloginJsp.jsp
--helloJsp.jsp
<?xml version="1.0" encoding="UTF-8"?>
<xml-body>
<struts>
<package name="Helloword" namespace="/" extends="struts-default">
<action name="Helloword" class="mypackage.Helloword">
<result >/WebRoot/helloJsp.jsp</result></action>
</package>
</struts>
</xml-body>
好像不用加前面的/WebRoot
应该是:<result>/helloJsp.jsp</result>
HTTP Status 404 - /Thestructs21/Helloword.action 这里面变成Thestructs21了。。
工程名这个不是问题的
我用http://localhost:8080/Thestructs21/WebRoot/MyloginJsp.jsp是能正常访问的