欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

在ssh项目中,提交form不能转到相应的Action上 SSHStrutsWebBeanSpring 

程序员文章站 2022-03-16 12:04:39
...
在ssh项目中,提交form不能转到相应的Action上,应该不是struts.jar的问题,我已经加到了lib目录下,web.xml配置文件不知道哟没有问题,请各位同僚帮忙看看。
web.xml如下:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.4"
	xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee   http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
	<context-param>
		<param-name>
			javax.servlet.jsp.jstl.fmt.localizationContext
		</param-name>
		<param-value>ApplicationResources</param-value>
	</context-param>
	<filter>
		<filter-name>encoding filter</filter-name>
		<filter-class>
			com.bluedot.web.filter.EncodiingFilter
		</filter-class>
		<init-param>
			<param-name>encoding</param-name>
			<param-value>UTF-8</param-value>
		</init-param>
	</filter>
	<filter-mapping>
		<filter-name>encoding filter</filter-name>
		<url-pattern>*.do</url-pattern>
	</filter-mapping>
	<filter-mapping>
		<filter-name>encoding filter</filter-name>
		<url-pattern>*.jsp</url-pattern>
	</filter-mapping>
	<servlet>
		<servlet-name>action</servlet-name>
		<servlet-class>
			org.apache.struts.action.ActionServlet
		</servlet-class>
		<init-param>
			<param-name>config</param-name>
			<param-value>/WEB-INF/struts-config.xml</param-value>
		</init-param>
		<init-param>
			<param-name>debug</param-name>
			<param-value>3</param-value>
		</init-param>
		<init-param>
			<param-name>detail</param-name>
			<param-value>3</param-value>
		</init-param>
		<load-on-startup>0</load-on-startup>
	</servlet>
	<servlet-mapping>
		<servlet-name>action</servlet-name>
		<url-pattern>*.do</url-pattern>
	</servlet-mapping>
	<welcome-file-list>
		<welcome-file>login.jsp</welcome-file>
	</welcome-file-list>
	<jsp-config>
		<taglib>
			<taglib-uri>/html</taglib-uri>
			<taglib-location>/WEB-INF/struts-html.tld</taglib-location>
		</taglib>
		<taglib>
			<taglib-uri>/bean</taglib-uri>
			<taglib-location>/WEB-INF/struts-bean.tld</taglib-location>
		</taglib>
		<taglib>
			<taglib-uri>/logic</taglib-uri>
			<taglib-location>/WEB-INF/struts-logic.tld</taglib-location>
		</taglib>
		<taglib>
			<taglib-uri>/tiles</taglib-uri>
			<taglib-location>/WEB-INF/struts-tiles.tld</taglib-location>
		</taglib>
		<taglib>
			<taglib-uri>/menu</taglib-uri>
			<taglib-location>/WEB-INF/struts-menu.tld</taglib-location>
		</taglib>
	</jsp-config>
</web-app>



struts-config.xml如下:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.2//EN" "http://struts.apache.org/dtds/struts-config_1_2.dtd">

<struts-config>

  <form-beans >
  	<form-bean name="userInfo" type="com.bluedot.web.forms.UserForm"/>
  	<form-bean name="studentForm" type="com.bluedot.web.forms.StudentForm"/>
  	<form-bean name="localLanguage" type="org.apache.struts.action.DynaActionForm">
  		<form-property name="country" type="java.lang.String"/>
  		<form-property name="language" type="java.lang.String"/>
  		<form-property name="page" type="java.lang.String"/>
  	</form-bean>
  	<form-bean name="paginationForm" type="org.apache.struts.action.DynaActionForm">
  		<form-property name="rowsPerPage" type="java.lang.String"/>
  		<form-property name="currentPageNo" type="java.lang.String"/>
  	</form-bean>
  </form-beans>
  <global-exceptions />
  <global-forwards >
  </global-forwards>
  <action-mappings >
  <action path="/main" forward="/login.jsp"/>
  <action path="/SwitchLocale" type="org.apache.struts.actions.LocaleAction" name="localLanguage"/>
  
  	<action path="/login"
  			type="org.springframework.web.struts.DelegatingActionProxy"
  			name="userInfo"
  			scope="session"
  			input="/login.jsp"
  			validate="true"
  	>
  		<forward name="success" path="mother.layout"/>
  	</action>
  	<action path="/toStudentManager" forward="student.manage.layout"/>
  	
  	<action path="/manageStudent"
  			type="org.springframework.web.struts.DelegatingActionProxy"
  			name="studentForm"
  			scope="session"
  			input="/studentManager.jsp"
  			validate="false"
  			parameter="action">
  		<forward name="success" path="student.manage.layout"/>
  	</action>
  	<action path="/toManageStudent"
  			type="org.springframework.web.struts.DelegatingActionProxy"
  			name="studentForm"
  			scope="session"
  			validate="false">
  		<forward name="success" path="student.manage.layout"/>
  	</action>
  	<action path="/studentPagination"
  			type="org.springframework.web.struts.DelegatingActionProxy"
  			name="paginationForm">
  		<forward name="success" path="student.manage.layout"/>
  	</action>		
  </action-mappings>
  <!-- Tiles框架请求处理器 -->
  <controller processorClass="org.apache.struts.tiles.TilesRequestProcessor" contentType="text/html;charset=UTF-8"/>
  
  <message-resources parameter="ApplicationResources"/>
    <plug-in className="org.apache.struts.validator.ValidatorPlugIn">
		<set-property property="pathnames"
					value="/WEB-INF/validator-rules.xml,/WEB-INF/myvlidation.xml" />
	</plug-in>
	<plug-in className="org.apache.struts.tiles.TilesPlugin">
		<set-property property="definitions-config"
			value="/WEB-INF/myTiles.xml" />
		<set-property property="definitions-debug" value="2" />
		<set-property property="definitions-parser-details" value="2" />
		<set-property property="definitions-parser-validate"
			value="true" />
	</plug-in>
	<plug-in className="net.sf.navigator.menu.MenuPlugIn">
		<set-property property="menuConfig"
			value="/WEB-INF/menu-config.xml" />
	</plug-in>
	<plug-in className="com.bluedot.plugin.HibernatePlugIn">
		<set-property property="configFilePath" value="/WEB-INF/classes/hibernate.cfg.xml"/>
		<set-property property="storeInServletContext" value="true"/>
	</plug-in>
	<plug-in className="org.springframework.web.struts.ContextLoaderPlugIn">
		<set-property property="contextConfigLocation" value="classpath:applicationContext.xml,/WEB-INF/action-servlet.xml"/>
	</plug-in>
</struts-config>



请求页面如下:

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    
 <%@ taglib uri="/html" prefix="html"%>
 <%@ taglib uri="/bean" prefix="bean"%>    
 <%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>   
<!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>
<div style="text-align:center">
<h1><html:errors property="userInfo"/></h1>
	<html:form action="login.do">
		<p><bean:message key="user.username"/>:<html:text property="userName"/><html:errors property="userName"/></p>
		<p><bean:message key="user.password"/>:<html:password property="password"/><html:errors property="password"/></p>
		<p><html:submit><bean:message key="button.submit"/></html:submit></p>
	</html:form>
	<html:link href="SwitchLocale.do?country=CN&language=zh&page=/main.do"><bean:message key="language.chinese"/></html:link><br>
	<html:link href="SwitchLocale.do?country=US&language=en&page=/main.do"><bean:message key="language.english"/></html:link>
	</div>
</body>
</html>