?
<html>

<head>
    <meta http - equiv="Content-Type" content="text/html;  charset=ISO-8859-1">
    <title>Insert title here
        < /title>
            < /head>

                <body>
                    <font face="verdana" size="2">
    $ {
        welcomeMessage
    } 
</font> 
                </body>

</html>

?

Spring MVC Program


javaserver page

Required Files:

1.index.jsp:

2.Java8sController.java:

3.web.xml

4.spring-servlet.xml

5.welcome.jsp

 

index.jsp

< html > 
    <
    head > 
    <
    meta  http - equiv = "Content-Type"
content = "text/html;   charset=ISO-8859-1" > 
    <
    title >  Insert title here < /title> <
    /head> <
    body > 
    <
    font size = "2px"
face = "verdana" >
    Welcome 2 SILAN Technology...
    <
    a href = "java8s.html" > Click  Here < /a >; <
    /body><
    /html>

Java8sController.java

package java8s;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
@Controller 
public class Java8sController {
    @RequestMapping("/java8s")
    public ModelAndView helloWorld() {
        String message = "Welcome to Java8s.com";
        message += "
        You Did it....!"; 
        return new ModelAndView("welcomeP", "welcomeMessage", message);
    }
}

web.xml

<< ? xml version = "1.0"
encoding = "UTF-8" ? >
    <
    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"> 
    <
    servlet >
    <
    servlet - name > welcome < /servlet-name > <
    servlet - class > org.springframework.web.servlet.DispatcherServlet < /servlet-class > <
    load - on - startup > 1 < /load-on-startup>  <
    servlet >
    <
    servlet - mapping >
    <
    servlet - name > welcome < /servlet-name > <
    url - pattern > / </url - pattern >
    <
    /servlet-mapping> <
    welcome - file - list >
    <
    welcome - file > index.jsp < /welcome-file > <
    /welcome-file-list>

spring-servlet.xml

<< ? xml version = "1.0"
encoding = "UTF-8" ? > < beans xmlns = "http://www.springframework.org/schema/beans"
xmlns: context = "http://www.springframework.org/schema/context"
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
    http: //www.springframework.org/schema/context
    http: //www.springframework.org/schema/context/spring-context-3.0.xsd">

    <
    context: component - scan base - package = "java8s" / >

    <
    bean class = "org.springframework.web.servlet.view.InternalResourceViewResolver" >
    <
    property name = "prefix"
value = "/jsp/" / >
    <
    property name = "suffix"
value = ".jsp" / >
    <
    /bean>

    <
    /beans>

Welcome.jsp

 html >
    <
    head >
    <
    meta http - equiv = "Content-Type"
content = "text/html;  charset=ISO-8859-1" >
    <
    title > Insert title here < /title> <
    /head> <
    body >
    <
    font face = "verdana"
size = "2" >
    $ {
        welcomeMessage
    } <
    /font> <
    /body> <
    /html>


Output:

javaserver page
javaserver page

Our Services:

Java Training | Python Training | Machine Learning with Python Training | Deep Learning with Python Training | Data Science with Python Training | Projects

SILAN Technology, BBSR
Call to: 0674-2361252

Comment