본문 바로가기
Struts

There is no Action mapped for namespace / and action name . - [unknown location]

by 수앙 2011. 7. 22.

Struts 2.2.3 사용

 

web.xml 작성

<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>

 

struts.properties 파일 변경없이 톰캣을 실행하면 예외가 발생한다.

There is no Action mapped for namespace / and action name . - [unknown location]
 at com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:189)
 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:58)
 at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:488)
 at org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)
 at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:91)
 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:127)
 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:298)
 at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
 at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
 at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
 at java.lang.Thread.run(Thread.java:595)

 

이유는 struts.properties 파일에

struts.action.extension=action,,

이렇게 정의되어 있는데 action,, 에서 ,, 콤마 2개가 비어있는 url 맵핑을 하려는데 action이 없어서 발생한 것이다.

그러므로 action만 쓰던가 action,do 이런식으로 특정 확장명을 명시해주면 된다.

 

다른 방법으로는

<filter>
	<filter-name>struts2</filter-name>
	<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
	<init-param>
		<param-name>actionPackages</param-name>
		<param-value>com.mycompany.myapp.actions</param-value>
	</init-param>
</filter>
<filter-mapping>
	<filter-name>struts2</filter-name>
	<url-pattern>*.action</url-pattern>
</filter-mapping>

이런 방식으로 filter-mapping 값을 특정 확장명으로 맵핑해주면 된다.

 

끝.

댓글