commons-spring/src/main/java/com/xiongyingqi/util/SpringMVCHelper.java
public static Collection<String> getAnnotationMappedPaths(Package pkg) {
		if (pkg == null) {
			return null;
		}
		Collection<String> rs = new LinkedHashSet<String>();
		Set<Class<?>> classes = PackageUtil.getclass(pkg);
		for (Iterator iterator = classes.iterator(); iterator.hasNext();) {
			Class<?> clazz = (Class<?>) iterator.next();
			if (clazz.isAnnotationPresent(Controller.class)) {
				String[] clazzPaths = null;
				if (clazz.isAnnotationPresent(RequestMapping.class)) {
					RequestMapping typeMapping = clazz.getAnnotation(RequestMapping.class);
					clazzPaths = typeMapping.value();
				}

				String[] methodPaths = null;
				Collection<String> methodPathCollection = new ArrayList<String>();
				Method[] methods = clazz.getDeclaredMethods();
				for (int i = 0; i < methods.length; i++) {
					Method method = methods[i];
					if (method.isAnnotationPresent(RequestMapping.class)) {
						RequestMapping typeMapping = method.getAnnotation(RequestMapping.class);
						String[] methodPathsVar = typeMapping.value();
						Collections.addAll(methodPathCollection, methodPathsVar);
					}
				}
				if (methodPathCollection.size() > 0) {
					methodPaths = methodPathCollection.toArray(new String[] {});
				}

				if (clazzPaths != null && clazzPaths.length > 0 && methodPaths != null
						&& methodPaths.length > 0) {
					for (int i = 0; i < clazzPaths.length; i++) {
						String typePath = clazzPaths[i];
						typePath = checkForPath(typePath);
						for (int j = 0; j < methodPaths.length; j++) {
							String methodPath = methodPaths[j];
							methodPath = checkForPath(methodPath);
							String mappedPath = typePath + methodPath;
							rs.add(mappedPath);
						}
					}
				} else if ((clazzPaths != null && clazzPaths.length > 0)
						&& (methodPaths == null || methodPaths.length == 0)) {
					for (int i = 0; i < clazzPaths.length; i++) {
						String typePath = clazzPaths[i];
						typePath = checkForPath(typePath);
						rs.add(typePath);
					}
				} else if ((methodPaths != null && methodPaths.length > 0)
						&& (clazzPaths == null || clazzPaths.length == 0)) {
                    EntityHelper.print(methodPaths);
                    for (int i = 0; i < clazzPaths.length; i++) {
						String typePath = clazzPaths[i];
						typePath = checkForPath(typePath);
						rs.add(typePath);
					}
				}
			}
		}
		return rs;
	}
public static Collection<String> getAnnotationMappedPaths(Package pkg) {
		if (pkg == null) {
			return null;
		}
		Collection<String> rs = new LinkedHashSet<String>();
		Set<Class<?>> classes = PackageUtil.getclass(pkg);
		for (Iterator iterator = classes.iterator(); iterator.hasNext();) {
			Class<?> clazz = (Class<?>) iterator.next();
			if (clazz.isAnnotationPresent(Controller.class)) {
				String[] clazzPaths = null;
				if (clazz.isAnnotationPresent(RequestMapping.class)) {
					RequestMapping typeMapping = clazz.getAnnotation(RequestMapping.class);
					clazzPaths = typeMapping.value();
				}

				String[] methodPaths = null;
				Collection<String> methodPathCollection = new ArrayList<String>();
				Method[] methods = clazz.getDeclaredMethods();
				for (int i = 0; i < methods.length; i++) {
					Method method = methods[i];
					if (method.isAnnotationPresent(RequestMapping.class)) {
						RequestMapping typeMapping = method.getAnnotation(RequestMapping.class);
						String[] methodPathsVar = typeMapping.value();
						Collections.addAll(methodPathCollection, methodPathsVar);
					}
				}
				if (methodPathCollection.size() > 0) {
					methodPaths = methodPathCollection.toArray(new String[] {});
				}

				if (clazzPaths != null && clazzPaths.length > 0 && methodPaths != null
						&& methodPaths.length > 0) {
					for (int i = 0; i < clazzPaths.length; i++) {
						String typePath = clazzPaths[i];
						typePath = checkForPath(typePath);
						for (int j = 0; j < methodPaths.length; j++) {
							String methodPath = methodPaths[j];
							methodPath = checkForPath(methodPath);
							String mappedPath = typePath + methodPath;
							rs.add(mappedPath);
						}
					}
				} else if ((clazzPaths != null && clazzPaths.length > 0)
						&& (methodPaths == null || methodPaths.length == 0)) {
					for (int i = 0; i < clazzPaths.length; i++) {
						String typePath = clazzPaths[i];
						typePath = checkForPath(typePath);
						rs.add(typePath);
					}
				} else if ((methodPaths != null && methodPaths.length > 0)
						&& (clazzPaths == null || clazzPaths.length == 0)) {
                    EntityHelper.print(methodPaths);
                    for (int i = 0; i < clazzPaths.length; i++) {
						String typePath = clazzPaths[i];
						typePath = checkForPath(typePath);
						rs.add(typePath);
					}
				}
			}
		}
		return rs;
	}
获取包下所有被Controller注解的类所表示的路径 <br>
2013-10-17 下午1:02:45

@param pkg
@return