初次整合struts2和string,在用ant部署时遇到下面的问题
services-undeploy-absolute:
[undeploy] OK - Undeployed application at context path /ch23
[deploy] FAIL - Deployed application at context path /ch23 but context failed to startBUILD FAILED
E:\Workspace\ch23\build.xml:39: FAIL - Deployed application at context path /ch23 but context failed to start
网上查了一些资料,觉得是web.xml的问题
web.xml代码<?xml version="1.0" encoding="UTF-8"?>
<web-app 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>Welcome to Tomcat</display-name>
<description>
Java Web开发入门与精通
</description>
<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>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<jsp-config>
<taglib>
<taglib-uri>/spring</taglib-uri>
<taglib-location>/WEB-INF/spring.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/struts-tags</taglib-uri>
<taglib-location>/WEB-INF/struts-tags.tld</taglib-location>
</taglib>
</jsp-config>
</web-app>然后我把<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>
去掉,ant部署成功,但是这个时候主页的login.jsp打不开
报错如下
description The server encountered an internal error () that prevented it from fulfilling this request.exception org.apache.jasper.JasperException: An exception occurred processing JSP page /login.jsp at line 74: <head><title>鐧婚檰</title></head>
5: <body>
6: <table>
7: <s:form id="id" action="login">
8: <s:textfield name="username" key="username"/>
9: <s:password name="password1" key="password1"/>
10: <s:submit key="submit"/>
Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:553)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:457)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:389)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:333)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
root cause The Struts dispatcher cannot be found. This is usually caused by using Struts tags without the associated filter. Struts tags are only usable when the request has passed through its servlet filter, which initializes the Struts dispatcher needed for this tag. - [unknown location]
org.apache.struts2.views.jsp.TagUtils.getStack(TagUtils.java:60)
org.apache.struts2.views.jsp.StrutsBodyTagSupport.getStack(StrutsBodyTagSupport.java:44)
org.apache.struts2.views.jsp.ComponentTagSupport.doStartTag(ComponentTagSupport.java:48)
org.apache.jsp.login_jsp._jspx_meth_s_005fform_005f0(login_jsp.java:114)
org.apache.jsp.login_jsp._jspService(login_jsp.java:84)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:419)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:389)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:333)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
note The full stack trace of the root cause is available in the Apache Tomcat/7.0.16 logs.
--------------------------------------------------------------------------------Apache Tomcat/7.0.16
根据This is usually caused by using Struts tags without the associated filter.
看意思好像是少了filter,但是加上上面的filter以后ant又报错,甚是不解
login.jsp源代码如下<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="s" uri="/struts-tags" %>
<html>
<head><title>登陆</title></head>
<body>
<table>
<s:form id="id" action="login">
<s:textfield name="username" key="username"/>
<s:password name="password1" key="password1"/>
<s:submit key="submit"/>
</s:form>
</table>
</body>
</html>
希望各位能抽出宝贵的时间帮小弟看看错误出在哪了
services-undeploy-absolute:
[undeploy] OK - Undeployed application at context path /ch23
[deploy] FAIL - Deployed application at context path /ch23 but context failed to startBUILD FAILED
E:\Workspace\ch23\build.xml:39: FAIL - Deployed application at context path /ch23 but context failed to start
网上查了一些资料,觉得是web.xml的问题
web.xml代码<?xml version="1.0" encoding="UTF-8"?>
<web-app 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>Welcome to Tomcat</display-name>
<description>
Java Web开发入门与精通
</description>
<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>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<jsp-config>
<taglib>
<taglib-uri>/spring</taglib-uri>
<taglib-location>/WEB-INF/spring.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/struts-tags</taglib-uri>
<taglib-location>/WEB-INF/struts-tags.tld</taglib-location>
</taglib>
</jsp-config>
</web-app>然后我把<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>
去掉,ant部署成功,但是这个时候主页的login.jsp打不开
报错如下
description The server encountered an internal error () that prevented it from fulfilling this request.exception org.apache.jasper.JasperException: An exception occurred processing JSP page /login.jsp at line 74: <head><title>鐧婚檰</title></head>
5: <body>
6: <table>
7: <s:form id="id" action="login">
8: <s:textfield name="username" key="username"/>
9: <s:password name="password1" key="password1"/>
10: <s:submit key="submit"/>
Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:553)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:457)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:389)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:333)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
root cause The Struts dispatcher cannot be found. This is usually caused by using Struts tags without the associated filter. Struts tags are only usable when the request has passed through its servlet filter, which initializes the Struts dispatcher needed for this tag. - [unknown location]
org.apache.struts2.views.jsp.TagUtils.getStack(TagUtils.java:60)
org.apache.struts2.views.jsp.StrutsBodyTagSupport.getStack(StrutsBodyTagSupport.java:44)
org.apache.struts2.views.jsp.ComponentTagSupport.doStartTag(ComponentTagSupport.java:48)
org.apache.jsp.login_jsp._jspx_meth_s_005fform_005f0(login_jsp.java:114)
org.apache.jsp.login_jsp._jspService(login_jsp.java:84)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:419)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:389)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:333)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
note The full stack trace of the root cause is available in the Apache Tomcat/7.0.16 logs.
--------------------------------------------------------------------------------Apache Tomcat/7.0.16
根据This is usually caused by using Struts tags without the associated filter.
看意思好像是少了filter,但是加上上面的filter以后ant又报错,甚是不解
login.jsp源代码如下<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="s" uri="/struts-tags" %>
<html>
<head><title>登陆</title></head>
<body>
<table>
<s:form id="id" action="login">
<s:textfield name="username" key="username"/>
<s:password name="password1" key="password1"/>
<s:submit key="submit"/>
</s:form>
</table>
</body>
</html>
希望各位能抽出宝贵的时间帮小弟看看错误出在哪了
解决方案 »
- tomcat里的日志 localhost.***.log中报的一个错误,看不懂,Cannot call sendError() after the respon
- 一个判断的业务逻辑,不会写了,请帮忙
- resin远程调试时为什么不会在断点处停下来呢??
- hibernate关联的种种疑问!
- 关于hibernate的疑问
- 求助,请帮我编一个宏程序
- 这样情况如何IoC
- 急问跪求!!!!!
- 请教各位高手(很急)(有点穷,少给一点分,表示敬意)
- jbuilder7自动生成注释的问题
- strutr2中的select标签,大家帮我看看
- Servlet.service() for servlet action threw exception
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>