test.jsp页面运行后
2009-2-3 17:23:05 com.opensymphony.xwork2.util.logging.commons.CommonsLogger warn
警告: Could not find action or result
There is no Action mapped for namespace / and action name checkimg. - [unknown location]
at com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:177)
at org.apache.struts2.impl.StrutsActionProxy.prepare(StrutsActionProxy.java:61)
at org.apache.struts2.impl.StrutsActionProxyFactory.createActionProxy(StrutsActionProxyFactory.java:39)
at com.opensymphony.xwork2.DefaultActionProxyFactory.createActionProxy(DefaultActionProxyFactory.java:47)
at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:458)
at org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:395)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:857)
at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:565)
at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1509)
at java.lang.Thread.run(Unknown Source)
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">
<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>
<servlet>
<servlet-name>img</servlet-name>
<servlet-class>com.check.img.Image</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>img</servlet-name>
<url-pattern>/checkimg</url-pattern>
</servlet-mapping>
</web-app>
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>
<package name="struts2" extends="struts-default">
<action name="login" class="com.test.action.LoginAction">
<result name="input">/admin/login.jsp</result>
<result name="success">/result.jsp</result>
<result name="failer">/admin/login.jsp</result>
</action>
</package>
</struts>
Image.java
package com.check.img;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.util.*;
import javax.imageio.*;
public class Image extends HttpServlet
{
private static final String CONTENT_TYPE = "text/html; charset=gb2312";
private Font mFont = new Font("Times New Roman", Font.PLAIN, 17);
public void init() throws ServletException
{
super.init();
}
Color getRandColor(int fc,int bc)
{
Random random = new Random();
if(fc>255) fc=255;
if(bc>255) bc=255;
int r=fc+random.nextInt(bc-fc);
int g=fc+random.nextInt(bc-fc);
int b=fc+random.nextInt(bc-fc);
return new Color(r,g,b);
}
public void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
response.setHeader("Pragma","No-cache");
response.setHeader("Cache-Control","no-cache");
response.setDateHeader("Expires", 0);
response.setContentType("image/jpeg");
int width=100, height=18;
BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
Graphics g = image.getGraphics();
Random random = new Random();
g.setColor(getRandColor(200,250));
g.fillRect(1, 1, width-1, height-1);
g.setColor(new Color(102,102,102));
g.drawRect(0, 0, width-1, height-1);
g.setFont(mFont);
g.setColor(getRandColor(160,200));
for (int i=0;i<155;i++)
{
int x = random.nextInt(width - 1);
int y = random.nextInt(height - 1);
int xl = random.nextInt(6) + 1;
int yl = random.nextInt(12) + 1;
g.drawLine(x,y,x + xl,y + yl);
}
for (int i = 0;i < 70;i++)
{
int x = random.nextInt(width - 1);
int y = random.nextInt(height - 1);
int xl = random.nextInt(12) + 1;
int yl = random.nextInt(6) + 1;
g.drawLine(x,y,x - xl,y - yl);
}
String sRand="";
for (int i=0;i<6;i++)
{
int itmp = random.nextInt(26) + 65;
char ctmp = (char)itmp;
sRand += String.valueOf(ctmp);
g.setColor(new Color(20+random.nextInt(110),20+random.nextInt(110),20+random.nextInt(110)));
g.drawString(String.valueOf(ctmp),15*i+10,16);
}
HttpSession session = request.getSession(true);
session.setAttribute("rand",sRand);
g.dispose();
ImageIO.write(image, "JPEG", response.getOutputStream());
}
public void destroy()
{
}
}
test.jsp
<%@ page language="java" contentType="text/html; charset=GBK"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Insert title here</title>
</head>
<body>
<img src="checkimg" />
</body>
</html>
11 个解决方案
#1
STRUTS2 的版本是 2.1.6
#2
<url-pattern>/* </url-pattern>
会不会是这个把下面的覆盖了
<url-pattern>/checkimg </url-pattern>
会不会是这个把下面的覆盖了
<url-pattern>/checkimg </url-pattern>
#3
这里怎么改啊??
<url-pattern>/* </url-pattern> 是不是代表STRUTS2 处理所有请求??
#4
我觉得很可能,struts1通常配置*.do
用*.action试试吧
用*.action试试吧
#5
fosjos 正解
#6
我用的是struts2 等下回去试试
#7
改成<url-pattern>*.action</url-pattern>吗?
test.jsp可以使用了
但是需要用到STRUTS2标签的网页就不行运行了,应该和这个filter的属性有关吧,*.action 是表示只处理action的请求了吧?
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: 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.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:522)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:416)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
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.admin.login_jsp._jspx_meth_s_005furl_005f0(login_jsp.java:118)
org.apache.jsp.admin.login_jsp._jspService(login_jsp.java:78)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
#8
把所有url-pattern都加上吧
#9
我也遇到这问题了 怎么解决呢
#10
loginSuccess
#11
我也遇到了这个问题,如果没有使用struts是没问题的,用了struts后就有问题了。告诉楼主吧,确实是
出问题了,你试试看,把它改成:
那么结果就不一样了。哈哈,问题是,怎么改回来呢???是个问题啊,大问题
<url-pattern>/*</url-pattern>
出问题了,你试试看,把它改成:
<url-pattern>/loginAction</url-pattern>,
那么结果就不一样了。哈哈,问题是,怎么改回来呢???是个问题啊,大问题
#1
STRUTS2 的版本是 2.1.6
#2
<url-pattern>/* </url-pattern>
会不会是这个把下面的覆盖了
<url-pattern>/checkimg </url-pattern>
会不会是这个把下面的覆盖了
<url-pattern>/checkimg </url-pattern>
#3
这里怎么改啊??
<url-pattern>/* </url-pattern> 是不是代表STRUTS2 处理所有请求??
#4
我觉得很可能,struts1通常配置*.do
用*.action试试吧
用*.action试试吧
#5
fosjos 正解
#6
我用的是struts2 等下回去试试
#7
改成<url-pattern>*.action</url-pattern>吗?
test.jsp可以使用了
但是需要用到STRUTS2标签的网页就不行运行了,应该和这个filter的属性有关吧,*.action 是表示只处理action的请求了吧?
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: 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.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:522)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:416)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
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.admin.login_jsp._jspx_meth_s_005furl_005f0(login_jsp.java:118)
org.apache.jsp.admin.login_jsp._jspService(login_jsp.java:78)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
#8
把所有url-pattern都加上吧
#9
我也遇到这问题了 怎么解决呢
#10
loginSuccess
#11
我也遇到了这个问题,如果没有使用struts是没问题的,用了struts后就有问题了。告诉楼主吧,确实是
出问题了,你试试看,把它改成:
那么结果就不一样了。哈哈,问题是,怎么改回来呢???是个问题啊,大问题
<url-pattern>/*</url-pattern>
出问题了,你试试看,把它改成:
<url-pattern>/loginAction</url-pattern>,
那么结果就不一样了。哈哈,问题是,怎么改回来呢???是个问题啊,大问题