jsp文件:
<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%> <!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>Index Page</title> </head> <body> <form action="register.action" method="post"> <select name="name"> <option value="ChinaFuction">ChinaFuction</option> <option value="UsaFunction">UsaFunction</option> </select> <input type="submit" value="确定"/> </form> </body> </html>
struts-xml文件:
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" "http://struts.apache.org/dtds/struts-2.0.dtd"> <struts> <include file="struts-default.xml" /> <package name="struts2" extends="struts-default" > <action name="register" class="com.fenfen.FuctionRegisterAction"> <result name="success">/success.jsp</result> </action> </package> </struts>
web-xml文件:
<?xml version="1.0" encoding="UTF-8"?> <web-app id="WebApp_ID" 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"> <display-name>myNewProj</display-name> <!-- 定义Struts2的FilterDispathcer的Filter --> <filter> <filter-name>struts2</filter-name> <filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class> </filter> <!-- FilterDispatcher用来初始化struts2并且处理所有的WEB请求。 --> <filter-mapping> <filter-name>struts2</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <welcome-file-list> <welcome-file>/indexfirst.jsp</welcome-file> </welcome-file-list> </web-app>
查了很多,原因最多是struts-xml文件放错位置,还有就是struts-xml文件配置错误。我的struts-xml文件放在了src文件夹下,应该没有放错地方,但是<?xml version="1.0" encoding="UTF-8"?>头文件报错。请大牛帮我看看配置有没有错误,O(∩_∩)O谢谢
能正确出现indexfirst.jsp页面,但是单击确定的时候报错。