Thursday, 15 March 2012

java - Access to jsp path with .action postfix in struts2 -



java - Access to jsp path with .action postfix in struts2 -

i have project using struts 2.1.8. project configured annotation using struts2-convention-plugin. here struts config in web.xml:

<filter> <filter-name>struts2filter</filter-name> <filter-class> org.apache.struts2.dispatcher.ng.filter.strutsprepareandexecutefilter</filter-class> </filter> <filter-mapping> <filter-name>struts2filter</filter-name> <url-pattern>*.jsp</url-pattern> </filter-mapping> <filter-mapping> <filter-name>struts2filter</filter-name> <url-pattern>/struts/*</url-pattern> </filter-mapping>

struts.xml:

<constant name="struts.convention.default.parent.package" value="borrow-default" /> <constant name="struts.convention.package.locators" value="action" /> <constant name="struts.convention.package.locators.basepackage" value="com.abc.action" /> <constant name="struts.convention.result.path" value="/" />

a.java:

@namespace("/regist") public class extends actionsupport{ @action(value="/a", results = {@result(location = "/a/test.jsp")}) public string execute(){ homecoming success; } }

here problem, can access test.jsp in url http://localhost:8080/a/test.jsp , http://localhost:8080/regist/a.action, can still visit same page in url http://localhost:8080/a/test.action. don't know why happens, what's wrong in config or code?

i tried other url, seems namespace doesn't take effect.

in web.xml url pattern like:

<url-pattern>/struts/*</url-pattern>

but placed jsp , getting /a/test.jsp 1 time check it...

java struts2 namespaces

No comments:

Post a Comment