按照Spring开发指南的步骤走,卡在了4红色部分
1.[Action.java]
<!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />-->
1
package
com.xc.sp;
2
3 public interface Action {
4
5 public String execute(String str);
6}
2
3 public interface Action {
4
5 public String execute(String str);
6}
2.[UpperAction.java]
Code
<!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />--> 1package com.xc.sp;
2
3import com.xc.sp.Action;
4
5public class UpperAction implements Action{
6
7 private String message;
8
9 public String getMessage(){
10 return message;
11 }
12
13 public void setMessage(String string){
14 message = string;
15 }
16
17 public String execute(String str){
18 return (getMessage() + str).toUpperCase();
19 }
20}
21
22
<!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />--> 1package com.xc.sp;
2
3import com.xc.sp.Action;
4
5public class UpperAction implements Action{
6
7 private String message;
8
9 public String getMessage(){
10 return message;
11 }
12
13 public void setMessage(String string){
14 message = string;
15 }
16
17 public String execute(String str){
18 return (getMessage() + str).toUpperCase();
19 }
20}
21
22
3.[testsp.java]
Code
<!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />--> 1package Test;
2
3import org.springframework.context.ApplicationContext;
4import org.springframework.context.support.FileSystemXmlApplicationContext;
5
6import com.xc.sp.Action;
7
8public class testsp {
9
10 /** *//**
11 * @param args
12 */
13 public static void main(String[] args) {
14 // TODO Auto-generated method stub
15 ApplicationContext ctx = new FileSystemXmlApplicationContext("bean.xml");
16 Action action = (Action) ctx.getBean("TheAction");
17 System.out.println(action.execute("Rod Johnson"));
18 }
19
20}
21
22
<!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />--> 1package Test;
2
3import org.springframework.context.ApplicationContext;
4import org.springframework.context.support.FileSystemXmlApplicationContext;
5
6import com.xc.sp.Action;
7
8public class testsp {
9
10 /** *//**
11 * @param args
12 */
13 public static void main(String[] args) {
14 // TODO Auto-generated method stub
15 ApplicationContext ctx = new FileSystemXmlApplicationContext("bean.xml");
16 Action action = (Action) ctx.getBean("TheAction");
17 System.out.println(action.execute("Rod Johnson"));
18 }
19
20}
21
22
4.[bean.xml]注意要有红色这部分
Code
<!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />--> 1<?xml version="1.0" encoding="UTF-8"?>
2<!DOCTYPE beans PUBLIC "-//SPRING/DTD BEAN/EN" "http://www.springframework.org/dtd/spring-beans.dtd">
3<beans>
4 <description>Spring Quick Start</description>
5 <bean id="TheAction" class="com.xc.sp.UpperAction">
6 <property name="message">
7 <value>HeLLo</value>
8 </property>
9 </bean>
10</beans>
11
12
<!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />--> 1<?xml version="1.0" encoding="UTF-8"?>
2<!DOCTYPE beans PUBLIC "-//SPRING/DTD BEAN/EN" "http://www.springframework.org/dtd/spring-beans.dtd">
3<beans>
4 <description>Spring Quick Start</description>
5 <bean id="TheAction" class="com.xc.sp.UpperAction">
6 <property name="message">
7 <value>HeLLo</value>
8 </property>
9 </bean>
10</beans>
11
12