Post Page Advertisement [Top]




まず、NewProjectでMavenをクリッくして進行してください。









適切なネームを付けてください。








下ではProjectの経路を設定してください。








ProjectNameで右クリックし、AddFrameworkSupportをクリックしてください。









SpringMVCをクリックしてください。









SpringMVCの追加の後、Webを右クリックしてViewsフォルダを作ってください。

その後、下にあるIndex.jspをViewsフォルダに移してください。









そしてweb.xmlの設定をします。



赤い箱のところを「*.form」にしてください。 











この写真に見える通り
javaフォルダの下にControllerのパッケージ(Package)を作ってください。
そしてその舌にcontrollerというClassを作って下のコードを入れてください。








package Controller;
import org.springframework.stereotype.Controller;import org.springframework.web.bind.annotation.RequestMapping;
@Controllerpublic class controller {

    @RequestMapping(value = "/")
    public String test(){
        return "index";    }
}








その次は 



WEB-INF フォルダの下

dispatcher-servlet.xmlを下のように設定してください。



<?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/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd"> <mvc:annotation-driven></mvc:annotation-driven> <context:component-scan base-package="Controller"></context:component-scan> <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="prefix" value="/WEB-INF/views/"></property> <property name="suffix" value=".jsp"></property> </bean> </beans>





これで全の準備は完了しました。
サーバーの設定が正しくできていれば問題なく起動すると思います。

댓글 없음:

댓글 쓰기

Bottom Ad [Post Page]

| Designed by Colorlib