add spring 4 mvc for worker
parent
31fb0048a1
commit
7fd27d9b22
@ -0,0 +1,20 @@
|
|||||||
|
package us.codecraft.webmagic.worker.web;
|
||||||
|
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
|
import org.springframework.web.servlet.ModelAndView;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author code4crafter@gmail.com
|
||||||
|
*/
|
||||||
|
@Controller("spider")
|
||||||
|
@RequestMapping("spider")
|
||||||
|
public class SpiderController {
|
||||||
|
|
||||||
|
@RequestMapping("create")
|
||||||
|
@ResponseBody
|
||||||
|
public ModelAndView create(){
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,21 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
|
||||||
|
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
|
||||||
|
|
||||||
|
<appender name="stdout" class="org.apache.log4j.ConsoleAppender">
|
||||||
|
<layout class="org.apache.log4j.PatternLayout">
|
||||||
|
<param name="ConversionPattern" value="%d{yy-MM-dd HH:mm:ss,SSS} %-5p %c(%F:%L) ## %m%n" />
|
||||||
|
</layout>
|
||||||
|
</appender>
|
||||||
|
|
||||||
|
<logger name="org.apache" additivity="false">
|
||||||
|
<level value="warn" />
|
||||||
|
<appender-ref ref="stdout" />
|
||||||
|
</logger>
|
||||||
|
|
||||||
|
<root>
|
||||||
|
<level value="info" />
|
||||||
|
<appender-ref ref="stdout" />
|
||||||
|
</root>
|
||||||
|
|
||||||
|
</log4j:configuration>
|
@ -0,0 +1,34 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||||
|
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
|
||||||
|
|
||||||
|
<bean id="freemarkerConfigurer"
|
||||||
|
class="org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer">
|
||||||
|
<property name="templateLoaderPath" value="/WEB-INF/pages/" />
|
||||||
|
<property name="defaultEncoding" value="utf-8" />
|
||||||
|
<property name="freemarkerSettings">
|
||||||
|
<props>
|
||||||
|
<prop key="template_update_delay">0</prop>
|
||||||
|
<prop key="locale">zh_CN</prop>
|
||||||
|
<prop key="datetime_format">yyyy-MM-dd HH:mm:ss</prop>
|
||||||
|
<prop key="date_format">yyyy-MM-dd</prop>
|
||||||
|
<prop key="number_format">#.##</prop>
|
||||||
|
</props>
|
||||||
|
</property>
|
||||||
|
</bean>
|
||||||
|
<!-- FreeMarker视图解析 如返回userinfo。。在这里配置后缀名ftl和视图解析器。。 -->
|
||||||
|
<bean id="viewResolver"
|
||||||
|
class="org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver">
|
||||||
|
<property name="viewClass"
|
||||||
|
value="org.springframework.web.servlet.view.freemarker.FreeMarkerView" />
|
||||||
|
<property name="suffix" value=".ftl" />
|
||||||
|
<property name="contentType" value="text/html;charset=utf-8" />
|
||||||
|
<property name="exposeRequestAttributes" value="true" />
|
||||||
|
<property name="exposeSessionAttributes" value="true" />
|
||||||
|
<property name="exposeSpringMacroHelpers" value="true" />
|
||||||
|
</bean>
|
||||||
|
|
||||||
|
|
||||||
|
</beans>
|
@ -0,0 +1,21 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||||
|
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
|
||||||
|
|
||||||
|
<!--<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">-->
|
||||||
|
<!--<property name="dataSource" ref="dataSource" />-->
|
||||||
|
<!--</bean>-->
|
||||||
|
|
||||||
|
<!--<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">-->
|
||||||
|
<!--<property name="basePackage" value="us.codecraft.blackhole.suite.dao" />-->
|
||||||
|
<!--</bean>-->
|
||||||
|
|
||||||
|
<!--<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"-->
|
||||||
|
<!--destroy-method="close">-->
|
||||||
|
<!--<property name="driverClassName" value="org.sqlite.JDBC" />-->
|
||||||
|
<!--<property name="url" value="jdbc:sqlite:/usr/local/hostd/zonesfile.db" />-->
|
||||||
|
<!--</bean>-->
|
||||||
|
|
||||||
|
</beans>
|
@ -0,0 +1,43 @@
|
|||||||
|
<?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:context="http://www.springframework.org/schema/context"
|
||||||
|
xmlns:mvc="http://www.springframework.org/schema/mvc"
|
||||||
|
xsi:schemaLocation="http://www.springframework.org/schema/mvc
|
||||||
|
http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
|
||||||
|
http://www.springframework.org/schema/beans
|
||||||
|
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
|
||||||
|
http://www.springframework.org/schema/context
|
||||||
|
http://www.springframework.org/schema/context/spring-context-3.0.xsd">
|
||||||
|
<context:annotation-config/>
|
||||||
|
|
||||||
|
<bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource">
|
||||||
|
<property name="basenames">
|
||||||
|
<list>
|
||||||
|
<value>web_messages</value>
|
||||||
|
</list>
|
||||||
|
</property>
|
||||||
|
</bean>
|
||||||
|
|
||||||
|
|
||||||
|
<context:component-scan base-package="us.codecraft.webmagic.worker"/>
|
||||||
|
<bean
|
||||||
|
class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
|
||||||
|
<property name="messageConverters">
|
||||||
|
<list>
|
||||||
|
<ref bean="jsonHttpMessageConverter"/>
|
||||||
|
</list>
|
||||||
|
</property>
|
||||||
|
</bean>
|
||||||
|
<bean id="jsonHttpMessageConverter" class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter"/>
|
||||||
|
|
||||||
|
<mvc:resources mapping="/js/**" location="/js/" />
|
||||||
|
<mvc:resources mapping="/css/**" location="/css/" />
|
||||||
|
<mvc:resources mapping="/img/**" location="/img/" />
|
||||||
|
<mvc:resources mapping="/font/**" location="/font/" />
|
||||||
|
|
||||||
|
|
||||||
|
<mvc:annotation-driven />
|
||||||
|
|
||||||
|
|
||||||
|
</beans>
|
@ -0,0 +1,12 @@
|
|||||||
|
<%@ page language="java" contentType="text/html; charset=utf8"
|
||||||
|
pageEncoding="utf8"%>
|
||||||
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=utf8">
|
||||||
|
<title>404</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>Page not found!</h1>
|
||||||
|
</body>
|
||||||
|
</html>
|
@ -0,0 +1,18 @@
|
|||||||
|
<%@ page language="java" contentType="text/html; charset=utf8"
|
||||||
|
pageEncoding="utf8" isErrorPage="true" import="java.io.*"%>
|
||||||
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=utf8">
|
||||||
|
<title>500</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
页面出错啦!
|
||||||
|
<%
|
||||||
|
|
||||||
|
StringWriter stringWriter = new StringWriter();
|
||||||
|
exception.printStackTrace(new PrintWriter(stringWriter));
|
||||||
|
out.println(stringWriter.toString());
|
||||||
|
%>
|
||||||
|
</body>
|
||||||
|
</html>
|
@ -0,0 +1,53 @@
|
|||||||
|
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
|
||||||
|
|
||||||
|
<display-name>Archetype Created Web Application</display-name>
|
||||||
|
|
||||||
|
<context-param>
|
||||||
|
<param-name>contextConfigLocation</param-name>
|
||||||
|
<param-value>
|
||||||
|
classpath*:spring/applicationContext*.xml,
|
||||||
|
</param-value>
|
||||||
|
</context-param>
|
||||||
|
|
||||||
|
<context-param>
|
||||||
|
<param-name>contextClass</param-name>
|
||||||
|
<param-value>org.springframework.web.context.support.XmlWebApplicationContext</param-value>
|
||||||
|
</context-param>
|
||||||
|
|
||||||
|
<!--由Sprng载入的Log4j配置文件位置 -->
|
||||||
|
<context-param>
|
||||||
|
<param-name>log4jConfigLocation</param-name>
|
||||||
|
<param-value>classpath:log/log4j.xml</param-value>
|
||||||
|
</context-param>
|
||||||
|
|
||||||
|
<context-param>
|
||||||
|
<param-name>log4jRefreshInterval</param-name>
|
||||||
|
<param-value>60000</param-value>
|
||||||
|
</context-param>
|
||||||
|
|
||||||
|
|
||||||
|
<servlet>
|
||||||
|
<servlet-name>spring</servlet-name>
|
||||||
|
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
|
||||||
|
<init-param>
|
||||||
|
<param-name>contextConfigLocation</param-name>
|
||||||
|
<param-value>classpath:/spring/applicationContext*.xml</param-value>
|
||||||
|
</init-param>
|
||||||
|
<load-on-startup>1</load-on-startup>
|
||||||
|
</servlet>
|
||||||
|
<servlet-mapping>
|
||||||
|
<servlet-name>spring</servlet-name>
|
||||||
|
<url-pattern>/</url-pattern>
|
||||||
|
</servlet-mapping>
|
||||||
|
<error-page>
|
||||||
|
<error-code>404</error-code>
|
||||||
|
<location>/WEB-INF/jsp/404.jsp</location>
|
||||||
|
</error-page>
|
||||||
|
<error-page>
|
||||||
|
<error-code>500</error-code>
|
||||||
|
<location>/WEB-INF/jsp/500.jsp</location>
|
||||||
|
</error-page>
|
||||||
|
|
||||||
|
</web-app>
|
Loading…
Reference in New Issue