用的是tomcat 6 +myeclipse8.5,在网上查了很久居然没有人遇到过,没有报错只是加载不完整。。。。
放在index.jsp里就显示完整!
放在login.jsp 就不行了。
这是web.xml的代码
<?xml version="1.0" encoding="UTF-8" ?>
<web-app id="WebApp_9" 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">
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<filter>
<filter-name>encodingFilter</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>encodingFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:applicationContext.xml</param-value>
</context-param>
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter>
<filter-name>oppensession</filter-name>
<filter-class>org.springframework.orm.hibernate4.support.OpenSessionInViewFilter</filter-class>
</filter>
</web-app>
struts2的配置文件
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
"http://struts.apache.org/dtds/struts-2.3.dtd">
<struts>
<!--<constant name="struts.enable.DyamicMethodInvocation" value="false"></constant>
<constant name="struts.devMode" value="false"></constant>
<constant name="struts.i18n.encoding" value="UTF-8" />
--><!--<constant name="struts.convention.result.path" value="/WEB-INF/pages"/>
<constant name="struts.convention.package.locators" value="web,action"/>
<constant name="struts.objectFactory" value="spring"/>
<constant name="struts.configuration.xml.reload" value="true"/>-->
<!--<constant name="struts.enable.DynamicMethodInvocation" value="true"></constant>-->
<package name="front" extends="struts-default">
<global-results>
<result name="fail">/index.jsp</result>
</global-results>
<global-exception-mappings>
<exception-mapping result="fail" exception="java.lang.Exception"></exception-mapping>
</global-exception-mappings>
</package>
<package name="ations" extends="front" namespace="/actions">
<action name="login" class="ua" method="login">
<result name="success">/admin/login_success.jsp</result>
<result name="fail">/admin/login_fail.jsp</result>
</action>
<action name="input" class="ua" method="input">
<result name="input">/login.jsp</result>
</action>
</package>
</struts>
页面的目录结构
login.jsp
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>用户登录</title>
<style type="text/css">
<!--