问题描述
我用的jetty7.6服务器,框架用的spring3+mybatis3+struts2,为何项目能正常启动,但是就是进不了action不管是form表单跳转,还是地址栏直接输入action都不行下面贴下我的文件内容:=================web.xml======================<?xmlversion="1.0"encoding="UTF-8"?><web-appid="web"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/j2eehttp://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"><display-name>application</display-name><distributable/><context-param><param-name>contextConfigLocation</param-name><param-value>classpath:spring.xml</param-value></context-param><!--定义Spring监听--><listener><listener-class>org.springframework.web.context.ContextLoaderListener</listener-class></listener><!--定义Log4j日志配置文件--><context-param><param-name>log4jConfigLocation</param-name><param-value>classpath:log4j.properties</param-value></context-param><!--定义日志监听--><listener><listener-class>org.springframework.web.util.Log4jConfigListener</listener-class></listener><!--Spring刷新Introspector防止内存泄露--><listener><listener-class>org.springframework.web.util.IntrospectorCleanupListener</listener-class></listener><filter><filter-name>struts2</filter-name><filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class></filter><filter><filter-name>encoding</filter-name><filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class><init-param><param-name>encoding</param-name><param-value>UTF-8</param-value></init-param></filter><filter-mapping><filter-name>encoding</filter-name><url-pattern>*.action</url-pattern></filter-mapping><filter-mapping><filter-name>struts2</filter-name><url-pattern>*.action</url-pattern></filter-mapping><!--Welcomefilelists--><welcome-file-list><welcome-file>index.jsp</welcome-file></welcome-file-list><error-page><error-code>404</error-code><location>/404ErrorPage.html</location></error-page><error-page><error-code>500</error-code><location>/500ErrorPage.html</location></error-page></web-app>
=======================struts.xml=======================<?xmlversion="1.0"encoding="UTF-8"?><!DOCTYPEstrutsPUBLIC"-//ApacheSoftwareFoundation//DTDStrutsConfiguration2.1//EN""http://struts.apache.org/dtds/struts-2.1.dtd"><struts><constantname="struts.devMode"value="false"/><constantname="struts.configuration.xml.reload"value="false"/><constantname="struts.i18n.encoding"value="UTF-8"/><constantname="struts.action.extension"value="action"/><constantname="struts.objectFactory"value="spring"/><constantname="struts.multipart.maxSize"value="2097152"/><constantname="struts.objectTypeDeterminer"value="tiger"/><constantname="struts.ui.theme"value="simple"/><constantname="struts.ognl.allowStaticMethodAccess"value="true"/><constantname="struts.freemarker.templatesCache"value="false"/><constantname="struts.custom.i18n.resources"value="application,global"/><constantname="struts.ui.templateDir"value="template"/><constantname="struts.objectFactory.spring.autoWire.alwaysRespect"value="true"/><packagename="user"namespace="/user"extends="struts-default"><actionname="userLogin.action"class="com.fyd.web.action.UserAction"method="login"><resultname="SUCCESS">/sendMail.jsp</result></action></package><packagename="default"namespace="/"extends="struts-default"><default-action-refname="index"/><actionname="index"class="com.fyd.web.action.UserAction"><resulttype="redirect">/index.jsp</result></action></package></struts>
=========================spring.xml============================<?xmlversion="1.0"encoding="UTF-8"?><beansxmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:context="http://www.springframework.org/schema/context"xmlns:aop="http://www.springframework.org/schema/aop"xmlns:tx="http://www.springframework.org/schema/tx"xsi:schemaLocation="http://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans-3.0.xsdhttp://www.springframework.org/schema/aophttp://www.springframework.org/schema/aop/spring-aop-3.0.xsdhttp://www.springframework.org/schema/txhttp://www.springframework.org/schema/tx/spring-tx-3.0.xsdhttp://www.springframework.org/schema/contexthttp://www.springframework.org/schema/context/spring-context-3.0.xsd"><!--采用注释的方式配置bean--><context:annotation-config/><!--配置要扫描的包--><context:component-scanbase-package="com.fyd"></context:component-scan><!--数据库配置文件位置--><context:property-placeholderlocation="classpath:jdbc.properties"/><!--配置dbcp数据源--><beanid="dataSource"class="org.apache.commons.dbcp.BasicDataSource"destroy-method="close"><propertyname="driverClassName"value="${jdbc.driverClassName}"/><propertyname="url"value="${jdbc.url}"/><propertyname="username"value="${jdbc.username}"/><propertyname="password"value="${jdbc.password}"/><!--队列中的最小等待数--><propertyname="minIdle"value="${jdbc.minIdle}"></property><!--队列中的最大等待数--><propertyname="maxIdle"value="${jdbc.maxIdle}"></property><!--最长等待时间,单位毫秒--><propertyname="maxWait"value="${jdbc.maxWait}"></property><!--最大活跃数--><propertyname="maxActive"value="${jdbc.maxActive}"></property><propertyname="initialSize"value="${jdbc.initialSize}"></property></bean><!--配置mybitasSqlSessionFactoryBean--><beanid="sqlSessionFactory"class="org.mybatis.spring.SqlSessionFactoryBean"><propertyname="dataSource"ref="dataSource"/><propertyname="configLocation"value="classpath:mybatis.xml"></property></bean><!--事务配置--><beanid="transactionManager"class="org.springframework.jdbc.datasource.DataSourceTransactionManager"><propertyname="dataSource"ref="dataSource"/></bean><!--使用annotation注解方式配置事务--><tx:annotation-driventransaction-manager="transactionManager"/></beans>
============================struts.properties===========================
解决方案二:
ThesecanbeusedtosetthedefaultHTTPandHTTPSportsstruts.url.http.port=80#webwork.url.https.port=443
解决方案三:
Thiscanbeusedtosetyourlocaleandencodingschemestruts.locale=zh_CNstruts.i18n.encoding=UTF-8
解决方案四:
ParsertohandleHTTPPOSTrequests,encodedusingtheMIME-typemultipart/form-data#webwork.multipart.parser=cosstruts.multipart.parser=jakarta#usesjavax.servlet.context.tempdirbydefaultwebwork.multipart.saveDir=tmpwebwork.multipart.maxSize=2097152struts.configuration.xml.reload=true#struts.mapper.class=com.opensymphony.webwork.dispatcher.mapper.DefaultActionMapperstruts.action.extension=actionstruts.objectFactory=spring
=========================mybatis.xml==========================<?xmlversion="1.0"encoding="UTF-8"?><!DOCTYPEconfigurationPUBLIC"-//mybatis.org//DTDConfig3.0//EN""http://mybatis.org/dtd/mybatis-3-config.dtd"><configuration><typeAliases><typeAliasalias="user"type="com.fyd.web.entity.User"/></typeAliases><mappers><mapperresource="com/fyd/web/ibatis/user.xml"/></mappers></configuration>
========================index.jsp========================<%@pagelanguage="java"contentType="text/html;charset=UTF-8"pageEncoding="UTF-8"%><%Stringpath=request.getContextPath();StringbasePath=request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";%><!DOCTYPEhtmlPUBLIC"-//W3C//DTDHTML4.01Transitional//EN""http://www.w3.org/TR/html4/loose.dtd"><html><head><metahttp-equiv="Content-Type"content="text/html;charset=utf-8"/><scriptdata-dojo-config="async:true,tlmSiblingOfDojo:true,deps:['application_client.js','application_server.js']"src="${pageContext.request.contextPath}/dojo/dojo.js.uncompressed.js"></script><scripttype="text/javascript">varconfig={contextPath:'${pageContext.request.contextPath}'};</script><title>登录</title></head><body><formaction="${pageContext.request.contextPath}/user/userLogin.action"method="post"id="loginForm">用户名:<inputname="user.username"type="text"/>密码:<inputname="user.password"type="password"/><inputtype="submit"value="提交"/></form></body></html>
报错截图如下
解决方案
本帖最后由 sparic 于 2014-10-11 11:29:04 编辑