Сравнение версий

Ключ

  • Эта строка добавлена.
  • Эта строка удалена.
  • Изменено форматирование.

...

Блок кода
<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<html>
<head>
 <title>Добро пожаловать</title>
</head>
<body>
<h4> Добро пожаловать! </h4>
Поздравляем, вы <b>${visitorCount}</b> посетитель и можете выиграть поездку в настолицу Java. - Джакарту <br/>

<a <script srchref="http://wwwclck.gmodules.com/ig/ifr?url=yandex.ru/redir/dtype=stred/pid=7/cid=1228/*http://wwwpogoda.googleyandex.com/ig/modules/builtin_weather.xml&amp;synd=open&amp;w=320&amp;h=200&amp;title=%D0%9F%D0%BE%D0%B3%D0%BE%D0%B4%D0%B0+%D0%BD%D0%B0+Java&amp;lang=en&amp;country=ALL&amp;border=%23ffffff%7C3px%2C1px+solid+%23999999&amp;output=js"></script>ru/jakarta"><img src="http://info.weather.yandex.net/jakarta/2.ru.png" border="0" alt=""/><img width="1" height="1" src="http://clck.yandex.ru/click/dtype=stred/pid=7/cid=1227/*http://img.yandex.ru/i/pix.gif" alt="" border="0"/></a>

</body>
</html>

Тут кроме HTML из интересного используется синтаксис Expression Language (EL) - ${visitorCount} для вывода значения переменной модели, которую мы установили в контроллере.вывода значения переменной модели, которую мы установили в контроллере.

Для того, чтобы можно было использовать EL, необходимо установить флаг isELIgnored="false", который по-умолчанию true для совместимости с предыдущими версиями JSP, где EL не интерпретировался.

 

Шаг 8: Конфигурация проекта для запуска  в Tomcat

...

Раскрыть
titleПример протокола успешного запуска
Блок кода
C:\Java\jdk1.6.0_10\bin\java -Dclassworlds.conf=C:\Java\apache-maven-2.2.1\bin\m2.conf -Dmaven.home=C:\Java\apache-maven-2.2.1 -Didea.launcher.port=7534 "-Didea.launcher.bin.path=C:\Program Files\JetBrains\IntelliJ IDEA 11.1.2\bin" -Dfile.encoding=UTF-8 -classpath "C:\Java\apache-maven-2.2.1\boot\classworlds-1.1.jar;C:\Program Files\JetBrains\IntelliJ IDEA 11.1.2\lib\idea_rt.jar" com.intellij.rt.execution.application.AppMain org.codehaus.classworlds.Launcher --no-plugin-registry --fail-fast --strict-checksums --update-snapshots -f "C:\Private\Dep806\Autumn2012\Java8\7 - Spring MVC\project\webapp\pom.xml" org.apache.tomcat.maven:tomcat6-maven-plugin:2.0:run
+ Enabling strict checksum verification on all artifact downloads.
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building webapp Maven Webapp
[INFO] task-segment: [org.apache.tomcat.maven:tomcat6-maven-plugin:2.0:run]
[INFO] ------------------------------------------------------------------------
[INFO] Preparing tomcat6:run
[INFO] [resources:resources {execution: default-resources}]
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO] [compiler:compile {execution: default-compile}]
[INFO] Nothing to compile - all classes are up to date
[INFO] [tomcat6:run {execution: default-cli}]
[INFO] Running war on http://localhost:8080/webapp
[INFO] Using existing Tomcat server configuration at C:\Private\Dep806\Autumn2012\Java8\7 - Spring MVC\project\webapp\target\tomcat
20.10.2012 3:38:41 org.apache.catalina.startup.Embedded start
INFO: Starting tomcat server
20.10.2012 3:38:41 org.apache.catalina.core.StandardEngine start
INFO: Starting Servlet Engine: Apache Tomcat/6.0.35
20.10.2012 3:38:42 org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring FrameworkServlet 'action'
20.10.2012 3:38:42 org.springframework.web.servlet.FrameworkServlet initServletBean
INFO: FrameworkServlet 'action': initialization started
20.10.2012 3:38:42 org.springframework.context.support.AbstractApplicationContext prepareRefresh
INFO: Refreshing WebApplicationContext for namespace 'action-servlet': startup date [Sat Oct 20 03:38:42 MSD 2012]; root of context hierarchy
20.10.2012 3:38:42 org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from ServletContext resource [/WEB-INF/action-servlet.xml]
20.10.2012 3:38:42 org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider registerDefaultFilters
INFO: JSR-250 'javax.annotation.ManagedBean' found and supported for component scanning
20.10.2012 3:38:42 org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletons
INFO: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@1891172: defining beans [welcomeController,org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,org.springframework.context.annotation.ConfigurationClassPostProcessor$ImportAwareBeanPostProcessor#0]; root of factory hierarchy
20.10.2012 3:38:43 org.springframework.web.servlet.handler.AbstractUrlHandlerMapping registerHandler
INFO: Mapped URL path [/index.html] onto handler 'welcomeController'
20.10.2012 3:38:43 org.springframework.web.servlet.FrameworkServlet initServletBean
INFO: FrameworkServlet 'action': initialization completed in 1390 ms
20.10.2012 3:38:43 org.apache.coyote.http11.Http11Protocol init
INFO: Initializing Coyote HTTP/1.1 on http-8080
20.10.2012 3:38:43 org.apache.coyote.http11.Http11Protocol start
INFO: Starting Coyote HTTP/1.1 on http-8080

Если все прошло успешно (в логах есть строка  INFO: FrameworkServlet 'action': initialization completed), то можно зайти на страницу по адресу http://localhost/webapp/index.html 

Image Added

Поздравляем с созданием первого MVC приложения!