struts+spring的注解

<?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>
	<!-- <constant name="struts.devMode" value="false" /> -->
	<!-- <constant name="struts.ui.theme" value="simple"></constant> -->
	<!-- ActionContext.getContext().put(key, object); -->
	<constant name="struts.objectFactory" value="org.apache.struts2.spring.StrutsSpringObjectFactory" />
	<constant name="struts.action.extension" value="do" />
	<constant name="struts.enable.SlashesInActionNames" value="true" />
	<constant name="struts.i18n.encoding" value="UTF-8"></constant>

	<package name="custom-default" extends="struts-default" abstract="true">
		<global-results>
			<result name="success">/WEB-INF/jsp/common/success.jsp</result>
			<result name="error">/WEB-INF/jsp/common/error.jsp</result>
			<result name="exception">/WEB-INF/jsp/common/error.jsp</result>
			<result type="redirect" name="loginPage">/login.jsp</result>
		</global-results>
		<global-exception-mappings>
			<exception-mapping result="exception" exception="java.lang.Throwable" />
		</global-exception-mappings>
	</package>
	
	<package name="admin" extends="custom-default" namespace="/admin">
		<action name="*/*/*" class="/admin/{1}/{2}" method="{3}"></action>
	</package>
	
</struts>

 

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.3//EN" "http://struts.apache.org/dtds/struts-config_1_3.dtd">

<struts-config>
	<form-beans>
		<form-bean name="producttypeform" type="cn.itcast.web.form.TestForm" />
	</form-beans>
	
	<global-forwards>
		<forward name="message" path="/WEB-INF/common/message.jsp" />
		<forward name="forward" path="/WEB-INF/common/forward.jsp" />
	</global-forwards>
	
	<action-mappings>
		<!-- 产品类别分页显示 -->
		<action path="/struts/test" name="producttypeform" scope="request" parameter="method" >
		</action>
	</action-mappings>

	<controller>
		<set-property property="processorClass"
			value="org.springframework.web.struts.DelegatingRequestProcessor" />
	</controller>
</struts-config>

 

import javax.servlet.http.HttpServletRequest;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.actions.DispatchAction;

@Controller("/admin/test/demo")
@Scope(value = "prototype")
public class BaseAction extends DispatchAction implements GloableURL
{

	public ActionForward returnUrl(String url, ActionMapping mapping, HttpServletRequest request)
	{
		if (url.indexOf(SPACE) < 0)
		{
			request.setAttribute(FORWARD, url);
		}
		else if (JSON.equals(url))
		{
			request.setAttribute(JSON, JSON);
		}
		else
		{
			String[] urls = url.split(SPACE);
			request.setAttribute(urls[0], urls[1]);
		}
		return mapping.findForward(FORWARD);
	}

	public ActionForward messageUrl(String url, ActionMapping mapping, HttpServletRequest request)
	{
		String[] urls = url.split(":");
		request.setAttribute(urls[0], urls[1]);
		return mapping.findForward("message");
	}
}

 

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"
	xmlns:tx="http://www.springframework.org/schema/tx" xmlns:context="http://www.springframework.org/schema/context"
	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
       http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
       http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">


	<context:annotation-config />
	<aop:aspectj-autoproxy />

	<context:component-scan base-package="com.app.cms" />
</beans>

 

你可能感兴趣的:(spring)