thymeleaf 相关问题

Thymeleaf是一个XML / XHTML / HTML5模板引擎(可扩展到其他格式),可以在Web和非Web环境中工作。它更适合在Web应用程序的视图层提供XHTML / HTML5,它甚至可以在脱机环境中处理任何XML文件。它提供了一个可选模块,用于与Spring MVC集成,因此您可以在使用此技术的应用程序中将其用作JSP的完全替代,即使使用HTML5也是如此。

Spring Boot ThymeLeaf 表单日期输入

我正在将 Spring Boot 与 ThymeLeaf 结合使用,无法在表单中获取正确的日期格式。 我可以格式化日期以在 HTML 元素中输出,例如 .保存用户输入的日期也有效。但将日期发送至...

回答 1 投票 0

SpringBoot 与 Thymeleaf - 未找到 css

首先要说的是,我已经寻找解决方案有一段时间了,现在我非常绝望。 当 Spring Boot 运行时,我无法从 html 页面访问 css 文件。 html.文件 ...

回答 10 投票 0


在使用 Thymeleaf 作为视图技术的应用程序中访问 swagger-ui.html

我正在使用 thymeleaf 开发一个 Java Web 应用程序 - 模板、Spring Security、swagger,用于应用程序中其余端点的 api 文档。一切都工作正常,除了...

回答 1 投票 0

Thymeaf 在 tomcat 上运行时无法解析模板

我有一个 springboot 应用程序,我将其配置为打包为 war,下面是我所做的更改。 pom.xml ... 战争 ... 组织。

回答 1 投票 0

如何将变量从我的 JS 文件传递到 Spring Boot 控制器?

下面是在我的视图页面中选择州和城市的代码(我使用的是thymeleaf 3) 下面是在我的视图页面中选择州和城市的代码(我使用的是thymeleaf 3) <div class="col-md-2"> <label for="inputCity" class="form-label">State</label> <select onchange="print_city('state', this.selectedIndex);" id="sts" name="stt" class="form-control" required> </select> </div> <div class="col-md-2"> <label for="inputCity" class="form-label">City</label> <select id="state" class="form-control" required> <option >Select State First</option> </select> <script language="javascript"> print_state("sts"); </script> </div> 我正在运行一个 JS 文件来填充下面的选择,这是代码(这是我从 github 获得的) var state_arr = new Array("Andaman & Nicobar", "Andhra Pradesh", "Arunachal Pradesh", "Assam", "Bihar", "Chandigarh", "Chhattisgarh", "Dadra & Nagar Haveli", "Daman & Diu", "Delhi", "Goa", "Gujarat", "Haryana", "Himachal Pradesh", "Jammu & Kashmir", "Jharkhand", "Karnataka", "Kerala", "Lakshadweep", "Madhya Pradesh", "Maharashtra", "Manipur", "Meghalaya", "Mizoram", "Nagaland", "Orissa", "Pondicherry", "Punjab", "Rajasthan", "Sikkim", "Tamil Nadu", "Tripura", "Uttar Pradesh", "Uttaranchal", "West Bengal"); var s_a = new Array(); s_a[0] = ""; s_a[1] = " Alipur | Andaman Island | Anderson Island | Arainj-Laka-Punga | Austinabad | Bamboo Flat | Barren Island | Beadonabad | Betapur | Bindraban | Bonington | Brookesabad | Cadell Point | Calicut | Chetamale | Cinque Islands | Defence Island | Digilpur | Dolyganj | Flat Island | Geinyale | Great Coco Island | Haddo | Havelock Island | Henry Lawrence Island | Herbertabad | Hobdaypur | Ilichar | Ingoie | Inteview Island | Jangli Ghat | Jhon Lawrence Island | Karen | Kartara | KYD Islannd | Landfall Island | Little Andmand | Little Coco Island | Long Island | Maimyo | Malappuram | Manglutan | Manpur | Mitha Khari | Neill Island | Nicobar Island | North Brother Island | North Passage Island | North Sentinel Island | Nothen Reef Island | Outram Island | Pahlagaon | Palalankwe | Passage Island | Phaiapong | Phoenix Island | Port Blair | Preparis Island | Protheroepur | Rangachang | Rongat | Rutland Island | Sabari | Saddle Peak | Shadipur | Smith Island | Sound Island | South Sentinel Island | Spike Island | Tarmugli Island | Taylerabad | Titaije | Toibalawe | Tusonabad | West Island | Wimberleyganj | Yadita"; s_a[2] = " Achampet | Adilabad | Adoni | Alampur | Allagadda | Alur | Amalapuram | Amangallu | Anakapalle | Anantapur | Andole | Araku | Armoor | Asifabad | Aswaraopet | Atmakur | B. Kothakota | Badvel | Banaganapalle | Bandar | Bangarupalem | Banswada | Bapatla | Bellampalli | Bhadrachalam | Bhainsa | Bheemunipatnam | Bhimadole | Bhimavaram | Bhongir | Bhooragamphad | Boath | Bobbili | Bodhan | Chandoor | Chavitidibbalu | Chejerla | Chepurupalli | Cherial | Chevella | Chinnor | Chintalapudi | Chintapalle | Chirala | Chittoor | Chodavaram | Cuddapah | Cumbum | Darsi | Devarakonda | Dharmavaram | Dichpalli | Divi | Donakonda | Dronachalam | East Godavari | Eluru | Eturnagaram | Gadwal | Gajapathinagaram | Gajwel | Garladinne | Giddalur | Godavari | Gooty | Gudivada | Gudur | Guntur | Hindupur | Hunsabad | Huzurabad | Huzurnagar | Hyderabad | Ibrahimpatnam | Jaggayyapet | Jagtial | Jammalamadugu | Jangaon | Jangareddygudem | Jannaram | Kadiri | Kaikaluru | Kakinada | Kalwakurthy | Kalyandurg | Kamalapuram | Kamareddy | Kambadur | Kanaganapalle | Kandukuru | Kanigiri | Karimnagar | Kavali | Khammam | Khanapur (AP) | Kodangal | Koduru | Koilkuntla | Kollapur | Kothagudem | Kovvur | Krishna | Krosuru | Kuppam | Kurnool | Lakkireddipalli | Madakasira | Madanapalli | Madhira | Madnur | Mahabubabad | Mahabubnagar | Mahadevapur | Makthal | Mancherial | Mandapeta | Mangalagiri | Manthani | Markapur | Marturu | Medachal | Medak | Medarmetla | Metpalli | Mriyalguda | Mulug | Mylavaram | Nagarkurnool | Nalgonda | Nallacheruvu | Nampalle | Nandigama | Nandikotkur | Nandyal | Narasampet | Narasaraopet | Narayanakhed | Narayanpet | Narsapur | Narsipatnam | Nazvidu | Nelloe | Nellore | Nidamanur | Nirmal | Nizamabad | Nuguru | Ongole | Outsarangapalle | Paderu | Pakala | Palakonda | Paland | Palmaneru | Pamuru | Pargi | Parkal | Parvathipuram | Pathapatnam | Pattikonda | Peapalle | Peddapalli | Peddapuram | Penukonda | Piduguralla | Piler | Pithapuram | Podili | Polavaram | Prakasam | Proddatur | Pulivendla | Punganur | Putturu | Rajahmundri | Rajampeta | Ramachandrapuram | Ramannapet | Rampachodavaram | Rangareddy | Rapur | Rayachoti | Rayadurg | Razole | Repalle | Saluru | Sangareddy | Sathupalli | Sattenapalle | Satyavedu | Shadnagar | Siddavattam | Siddipet | Sileru | Sircilla | Sirpur Kagaznagar | Sodam | Sompeta | Srikakulam | Srikalahasthi | Srisailam | Srungavarapukota | Sudhimalla | Sullarpet | Tadepalligudem | Tadipatri | Tanduru | Tanuku | Tekkali | Tenali | Thungaturthy | Tirivuru | Tirupathi | Tuni | Udaygiri | Ulvapadu | Uravakonda | Utnor | V.R. Puram | Vaimpalli | Vayalpad | Venkatgiri | Venkatgirikota | Vijayawada | Vikrabad | Vinjamuru | Vinukonda | Visakhapatnam | Vizayanagaram | Vizianagaram | Vuyyuru | Wanaparthy | Warangal | Wardhannapet | Yelamanchili | Yelavaram | Yeleswaram | Yellandu | Yellanuru | Yellareddy | Yerragondapalem | Zahirabad "; s_a[3] = " Along | Anini | Anjaw | Bameng | Basar | Changlang | Chowkhem | Daporizo | Dibang Valley | Dirang | Hayuliang | Huri | Itanagar | Jairampur | Kalaktung | Kameng | Khonsa | Kolaring | Kurung Kumey | Lohit | Lower Dibang Valley | Lower Subansiri | Mariyang | Mechuka | Miao | Nefra | Pakkekesang | Pangin | Papum Pare | Passighat | Roing | Sagalee | Seppa | Siang | Tali | Taliha | Tawang | Tezu | Tirap | Tuting | Upper Siang | Upper Subansiri | Yiang Kiag "; s_a[4] = " Abhayapuri | Baithalangshu | Barama | Barpeta Road | Bihupuria | Bijni | Bilasipara | Bokajan | Bokakhat | Boko | Bongaigaon | Cachar | Cachar Hills | Darrang | Dhakuakhana | Dhemaji | Dhubri | Dibrugarh | Digboi | Diphu | Goalpara | Gohpur | Golaghat | Guwahati | Hailakandi | Hajo | Halflong | Hojai | Howraghat | Jorhat | Kamrup | Karbi Anglong | Karimganj | Kokarajhar | Kokrajhar | Lakhimpur | Maibong | Majuli | Mangaldoi | Mariani | Marigaon | Moranhat | Morigaon | Nagaon | Nalbari | Rangapara | Sadiya | Sibsagar | Silchar | Sivasagar | Sonitpur | Tarabarihat | Tezpur | Tinsukia | Udalgiri | Udalguri | UdarbondhBarpeta"; s_a[5] = " Adhaura | Amarpur | Araria | Areraj | Arrah | Arwal | Aurangabad | Bagaha | Banka | Banmankhi | Barachakia | Barauni | Barh | Barosi | Begusarai | Benipatti | Benipur | Bettiah | Bhabhua | Bhagalpur | Bhojpur | Bidupur | Biharsharif | Bikram | Bikramganj | Birpur | Buxar | Chakai | Champaran | Chapara | Dalsinghsarai | Danapur | Darbhanga | Daudnagar | Dhaka | Dhamdaha | Dumraon | Ekma | Forbesganj | Gaya | Gogri | Gopalganj | H.Kharagpur | Hajipur | Hathua | Hilsa | Imamganj | Jahanabad | Jainagar | Jamshedpur | Jamui | Jehanabad | Jhajha | Jhanjharpur | Kahalgaon | Kaimur (Bhabua) | Katihar | Katoria | Khagaria | Kishanganj | Korha | Lakhisarai | Madhepura | Madhubani | Maharajganj | Mahua | Mairwa | Mallehpur | Masrakh | Mohania | Monghyr | Motihari | Motipur | Munger | Muzaffarpur | Nabinagar | Nalanda | Narkatiaganj | Naugachia | Nawada | Pakribarwan | Pakridayal | Patna | Phulparas | Piro | Pupri | Purena | Purnia | Rafiganj | Rajauli | Ramnagar | Raniganj | Raxaul | Rohtas | Rosera | S.Bakhtiarpur | Saharsa | Samastipur | Saran | Sasaram | Seikhpura | Sheikhpura | Sheohar | Sherghati | Sidhawalia | Singhwara | Sitamarhi | Siwan | Sonepur | Supaul | Thakurganj | Triveniganj | Udakishanganj | Vaishali | Wazirganj"; s_a[6] = " Chandigarh | Mani Marja"; s_a[7] = " Ambikapur | Antagarh | Arang | Bacheli | Bagbahera | Bagicha | Baikunthpur | Balod | Balodabazar | Balrampur | Barpalli | Basana | Bastanar | Bastar | Bderajpur | Bemetara | Berla | Bhairongarh | Bhanupratappur | Bharathpur | Bhatapara | Bhilai | Bhilaigarh | Bhopalpatnam | Bijapur | Bilaspur | Bodla | Bokaband | Chandipara | Chhinagarh | Chhuriakala | Chingmut | Chuikhadan | Dabhara | Dallirajhara | Dantewada | Deobhog | Dhamda | Dhamtari | Dharamjaigarh | Dongargarh | Durg | Durgakondal | Fingeshwar | Gariaband | Garpa | Gharghoda | Gogunda | Ilamidi | Jagdalpur | Janjgir | Janjgir-Champa | Jarwa | Jashpur | Jashpurnagar | Kabirdham-Kawardha | Kanker | Kasdol | Kathdol | Kathghora | Kawardha | Keskal | Khairgarh | Kondagaon | Konta | Korba | Korea | Kota | Koyelibeda | Kuakunda | Kunkuri | Kurud | Lohadigundah | Lormi | Luckwada | Mahasamund | Makodi | Manendragarh | Manpur | Marwahi | Mohla | Mungeli | Nagri | Narainpur | Narayanpur | Neora | Netanar | Odgi | Padamkot | Pakhanjur | Pali | Pandaria | Pandishankar | Parasgaon | Pasan | Patan | Pathalgaon | Pendra | Pratappur | Premnagar | Raigarh | Raipur | Rajnandgaon | Rajpur | Ramchandrapur | Saraipali | Saranggarh | Sarona | Semaria | Shakti | Sitapur | Sukma | Surajpur | Surguja | Tapkara | Toynar | Udaipur | Uproda | Wadrainagar"; s_a[8] = " Amal | Amli | Bedpa | Chikhli | Dadra & Nagar Haveli | Dahikhed | Dolara | Galonda | Kanadi | Karchond | Khadoli | Kharadpada | Kherabari | Kherdi | Kothar | Luari | Mashat | Rakholi | Rudana | Saili | Sili | Silvassa | Sindavni | Udva | Umbarkoi | Vansda | Vasona | Velugam "; s_a[9] = " Brancavare | Dagasi | Daman | Diu | Magarvara | Nagwa | Pariali | Passo Covo "; s_a[10] = " Central Delhi | East Delhi | New Delhi | North Delhi | North East Delhi | North West Delhi | South Delhi | South West Delhi | West Delhi "; s_a[11] = " Canacona | Candolim | Chinchinim | Cortalim | Goa | Jua | Madgaon | Mahem | Mapuca | Marmagao | Panji | Ponda | Sanvordem | Terekhol "; s_a[12] = " Ahmedabad | Ahwa | Amod | Amreli | Anand | Anjar | Ankaleshwar | Babra | Balasinor | Banaskantha | Bansada | Bardoli | Bareja | Baroda | Barwala | Bayad | Bhachav | Bhanvad | Bharuch | Bhavnagar | Bhiloda | Bhuj | Billimora | Borsad | Botad | Chanasma | Chhota Udaipur | Chotila | Dabhoi | Dahod | Damnagar | Dang | Danta | Dasada | Dediapada | Deesa | Dehgam | Deodar | Devgadhbaria | Dhandhuka | Dhanera | Dharampur | Dhari | Dholka | Dhoraji | Dhrangadhra | Dhrol | Dwarka | Fortsongadh | Gadhada | Gandhi Nagar | Gariadhar | Godhra | Gogodar | Gondal | Halol | Halvad | Harij | Himatnagar | Idar | Jambusar | Jamjodhpur | Jamkalyanpur | Jamnagar | Jasdan | Jetpur | Jhagadia | Jhalod | Jodia | Junagadh | Junagarh | Kalawad | Kalol | Kapad Wanj | Keshod | Khambat | Khambhalia | Khavda | Kheda | Khedbrahma | Kheralu | Kodinar | Kotdasanghani | Kunkawav | Kutch | Kutchmandvi | Kutiyana | Lakhpat | Lakhtar | Lalpur | Limbdi | Limkheda | Lunavada | M.M.Mangrol | Mahuva | Malia-Hatina | Maliya | Malpur | Manavadar | Mandvi | Mangrol | Mehmedabad | Mehsana | Miyagam | Modasa | Morvi | Muli | Mundra | Nadiad | Nakhatrana | Nalia | Narmada | Naswadi | Navasari | Nizar | Okha | Paddhari | Padra | Palanpur | Palitana | Panchmahals | Patan | Pavijetpur | Porbandar | Prantij | Radhanpur | Rahpar | Rajaula | Rajkot | Rajpipla | Ranavav | Sabarkantha | Sanand | Sankheda | Santalpur | Santrampur | Savarkundla | Savli | Sayan | Sayla | Shehra | Sidhpur | Sihor | Sojitra | Sumrasar | Surat | Surendranagar | Talaja | Thara | Tharad | Thasra | Una-Diu | Upleta | Vadgam | Vadodara | Valia | Vallabhipur | Valod | Valsad | Vanthali | Vapi | Vav | Veraval | Vijapur | Viramgam | Visavadar | Visnagar | Vyara | Waghodia | Wankaner "; s_a[13] = " Adampur Mandi | Ambala | Assandh | Bahadurgarh | Barara | Barwala | Bawal | Bawanikhera | Bhiwani | Charkhidadri | Cheeka | Chhachrauli | Dabwali | Ellenabad | Faridabad | Fatehabad | Ferojpur Jhirka | Gharaunda | Gohana | Gurgaon | Hansi | Hisar | Jagadhari | Jatusana | Jhajjar | Jind | Julana | Kaithal | Kalanaur | Kalanwali | Kalka | Karnal | Kosli | Kurukshetra | Loharu | Mahendragarh | Meham | Mewat | Mohindergarh | Naraingarh | Narnaul | Narwana | Nilokheri | Nuh | Palwal | Panchkula | Panipat | Pehowa | Ratia | Rewari | Rohtak | Safidon | Sirsa | Siwani | Sonipat | Tohana | Tohsam | Yamunanagar "; s_a[14] = " Amb | Arki | Banjar | Bharmour | Bilaspur | Chamba | Churah | Dalhousie | Dehra Gopipur | Hamirpur | Jogindernagar | Kalpa | Kangra | Kinnaur | Kullu | Lahaul | Mandi | Nahan | Nalagarh | Nirmand | Nurpur | Palampur | Pangi | Paonta | Pooh | Rajgarh | Rampur Bushahar | Rohru | Shimla | Sirmaur | Solan | Spiti | Sundernagar | Theog | Udaipur | Una"; s_a[15] = " Akhnoor | Anantnag | Badgam | Bandipur | Baramulla | Basholi | Bedarwah | Budgam | Doda | Gulmarg | Jammu | Kalakot | Kargil | Karnah | Kathua | Kishtwar | Kulgam | Kupwara | Leh | Mahore | Nagrota | Nobra | Nowshera | Nyoma | Padam | Pahalgam | Patnitop | Poonch | Pulwama | Rajouri | Ramban | Ramnagar | Reasi | Samba | Srinagar | Udhampur | Vaishno Devi "; s_a[16] = " Bagodar | Baharagora | Balumath | Barhi | Barkagaon | Barwadih | Basia | Bermo | Bhandaria | Bhawanathpur | Bishrampur | Bokaro | Bolwa | Bundu | Chaibasa | Chainpur | Chakardharpur | Chandil | Chatra | Chavparan | Daltonganj | Deoghar | Dhanbad | Dumka | Dumri | Garhwa | Garu | Ghaghra | Ghatsila | Giridih | Godda | Gomia | Govindpur | Gumla | Hazaribagh | Hunterganj | Ichak | Itki | Jagarnathpur | Jamshedpur | Jamtara | Japla | Jharmundi | Jhinkpani | Jhumaritalaiya | Kathikund | Kharsawa | Khunti | Koderma | Kolebira | Latehar | Lohardaga | Madhupur | Mahagama | Maheshpur Raj | Mandar | Mandu | Manoharpur | Muri | Nagarutatri | Nala | Noamundi | Pakur | Palamu | Palkot | Patan | Rajdhanwar | Rajmahal | Ramgarh | Ranchi | Sahibganj | Saraikela | Simaria | Simdega | Singhbhum | Tisri | Torpa "; s_a[17] = " Afzalpur | Ainapur | Aland | Alur | Anekal | Ankola | Arsikere | Athani | Aurad | Bableshwar | Badami | Bagalkot | Bagepalli | Bailhongal | Bangalore | Bangalore Rural | Bangarpet | Bantwal | Basavakalyan | Basavanabagewadi | Basavapatna | Belgaum | Bellary | Belthangady | Belur | Bhadravati | Bhalki | Bhatkal | Bidar | Bijapur | Biligi | Chadchan | Challakere | Chamrajnagar | Channagiri | Channapatna | Channarayapatna | Chickmagalur | Chikballapur | Chikkaballapur | Chikkanayakanahalli | Chikkodi | Chikmagalur | Chincholi | Chintamani | Chitradurga | Chittapur | Cowdahalli | Davanagere | Deodurga | Devangere | Devarahippargi | Dharwad | Doddaballapur | Gadag | Gangavathi | Gokak | Gowribdanpur | Gubbi | Gulbarga | Gundlupet | H.B.Halli | H.D. Kote | Haliyal | Hampi | Hangal | Harapanahalli | Hassan | Haveri | Hebri | Hirekerur | Hiriyur | Holalkere | Holenarsipur | Honnali | Honnavar | Hosadurga | Hosakote | Hosanagara | Hospet | Hubli | Hukkeri | Humnabad | Hungund | Hunsagi | Hunsur | Huvinahadagali | Indi | Jagalur | Jamkhandi | Jewargi | Joida | K.R. Nagar | Kadur | Kalghatagi | Kamalapur | Kanakapura | Kannada | Kargal | Karkala | Karwar | Khanapur | Kodagu | Kolar | Kollegal | Koppa | Koppal | Koratageri | Krishnarajapet | Kudligi | Kumta | Kundapur | Kundgol | Kunigal | Kurugodu | Kustagi | Lingsugur | Madikeri | Madugiri | Malavalli | Malur | Mandya | Mangalore | Manipal | Manvi | Mashal | Molkalmuru | Mudalgi | Muddebihal | Mudhol | Mudigere | Mulbagal | Mundagod | Mundargi | Murugod | Mysore | Nagamangala | Nanjangud | Nargund | Narsimrajapur | Navalgund | Nelamangala | Nimburga | Pandavapura | Pavagada | Puttur | Raibag | Raichur | Ramdurg | Ranebennur | Ron | Sagar | Sakleshpur | Salkani | Sandur | Saundatti | Savanur | Sedam | Shahapur | Shankarnarayana | Shikaripura | Shimoga | Shirahatti | Shorapur | Siddapur | Sidlaghatta | Sindagi | Sindhanur | Sira | Sirsi | Siruguppa | Somwarpet | Sorab | Sringeri | Sriniwaspur | Srirangapatna | Sullia | T. Narsipur | Tallak | Tarikere | Telgi | Thirthahalli | Tiptur | Tumkur | Turuvekere | Udupi | Virajpet | Wadi | Yadgiri | Yelburga | Yellapur "; s_a[18] = " Adimaly | Adoor | Agathy | Alappuzha | Alathur | Alleppey | Alwaye | Amini | Androth | Attingal | Badagara | Bitra | Calicut | Cannanore | Chetlet | Ernakulam | Idukki | Irinjalakuda | Kadamath | Kalpeni | Kalpetta | Kanhangad | Kanjirapally | Kannur | Karungapally | Kasargode | Kavarathy | Kiltan | Kochi | Koduvayur | Kollam | Kottayam | Kovalam | Kozhikode | Kunnamkulam | Malappuram | Mananthodi | Manjeri | Mannarghat | Mavelikkara | Minicoy | Munnar | Muvattupuzha | Nedumandad | Nedumgandam | Nilambur | Palai | Palakkad | Palghat | Pathaanamthitta | Pathanamthitta | Payyanur | Peermedu | Perinthalmanna | Perumbavoor | Punalur | Quilon | Ranni | Shertallai | Shoranur | Taliparamba | Tellicherry | Thiruvananthapuram | Thodupuzha | Thrissur | Tirur | Tiruvalla | Trichur | Trivandrum | Uppala | Vadakkanchery | Vikom | Wayanad "; s_a[19] = " Agatti Island | Bingaram Island | Bitra Island | Chetlat Island | Kadmat Island | Kalpeni Island | Kavaratti Island | Kiltan Island | Lakshadweep Sea | Minicoy Island | North Island | South Island "; s_a[20] = " Agar | Ajaigarh | Alirajpur | Amarpatan | Amarwada | Ambah | Anuppur | Arone | Ashoknagar | Ashta | Atner | Babaichichli | Badamalhera | Badarwsas | Badnagar | Badnawar | Badwani | Bagli | Baihar | Balaghat | Baldeogarh | Baldi | Bamori | Banda | Bandhavgarh | Bareli | Baroda | Barwaha | Barwani | Batkakhapa | Begamganj | Beohari | Berasia | Berchha | Betul | Bhainsdehi | Bhander | Bhanpura | Bhikangaon | Bhimpur | Bhind | Bhitarwar | Bhopal | Biaora | Bijadandi | Bijawar | Bijaypur | Bina | Birsa | Birsinghpur | Budhni | Burhanpur | Buxwaha | Chachaura | Chanderi | Chaurai | Chhapara | Chhatarpur | Chhindwara | Chicholi | Chitrangi | Churhat | Dabra | Damoh | Datia | Deori | Deosar | Depalpur | Dewas | Dhar | Dharampuri | Dindori | Gadarwara | Gairatganj | Ganjbasoda | Garoth | Ghansour | Ghatia | Ghatigaon | Ghorandogri | Ghughari | Gogaon | Gohad | Goharganj | Gopalganj | Gotegaon | Gourihar | Guna | Gunnore | Gwalior | Gyraspur | Hanumana | Harda | Harrai | Harsud | Hatta | Hoshangabad | Ichhawar | Indore | Isagarh | Itarsi | Jabalpur | Jabera | Jagdalpur | Jaisinghnagar | Jaithari | Jaitpur | Jaitwara | Jamai | Jaora | Jatara | Jawad | Jhabua | Jobat | Jora | Kakaiya | Kannod | Kannodi | Karanjia | Kareli | Karera | Karhal | Karpa | Kasrawad | Katangi | Katni | Keolari | Khachrod | Khajuraho | Khakner | Khalwa | Khandwa | Khaniadhana | Khargone | Khategaon | Khetia | Khilchipur | Khirkiya | Khurai | Kolaras | Kotma | Kukshi | Kundam | Kurwai | Kusmi | Laher | Lakhnadon | Lamta | Lanji | Lateri | Laundi | Maheshwar | Mahidpurcity | Maihar | Majhagwan | Majholi | Malhargarh | Manasa | Manawar | Mandla | Mandsaur | Manpur | Mauganj | Mawai | Mehgaon | Mhow | Morena | Multai | Mungaoli | Nagod | Nainpur | Narsingarh | Narsinghpur | Narwar | Nasrullaganj | Nateran | Neemuch | Niwari | Niwas | Nowgaon | Pachmarhi | Pandhana | Pandhurna | Panna | Parasia | Patan | Patera | Patharia | Pawai | Petlawad | Pichhore | Piparia | Pohari | Prabhapattan | Punasa | Pushprajgarh | Raghogarh | Raghunathpur | Rahatgarh | Raisen | Rajgarh | Rajpur | Ratlam | Rehli | Rewa | Sabalgarh | Sagar | Sailana | Sanwer | Sarangpur | Sardarpur | Satna | Saunsar | Sehore | Sendhwa | Seondha | Seoni | Seonimalwa | Shahdol | Shahnagar | Shahpur | Shajapur | Sheopur | Sheopurkalan | Shivpuri | Shujalpur | Sidhi | Sihora | Silwani | Singrauli | Sirmour | Sironj | Sitamau | Sohagpur | Sondhwa | Sonkatch | Susner | Tamia | Tarana | Tendukheda | Teonthar | Thandla | Tikamgarh | Timarani | Udaipura | Ujjain | Umaria | Umariapan | Vidisha | Vijayraghogarh | Waraseoni | Zhirnia "; s_a[21] = " Achalpur | Aheri | Ahmednagar | Ahmedpur | Ajara | Akkalkot | Akola | Akole | Akot | Alibagh | Amagaon | Amalner | Ambad | Ambejogai | Amravati | Arjuni Merogaon | Arvi | Ashti | Atpadi | Aurangabad | Ausa | Babhulgaon | Balapur | Baramati | Barshi Takli | Barsi | Basmatnagar | Bassein | Beed | Bhadrawati | Bhamregadh | Bhandara | Bhir | Bhiwandi | Bhiwapur | Bhokar | Bhokardan | Bhoom | Bhor | Bhudargad | Bhusawal | Billoli | Brahmapuri | Buldhana | Butibori | Chalisgaon | Chamorshi | Chandgad | Chandrapur | Chandur | Chanwad | Chhikaldara | Chikhali | Chinchwad | Chiplun | Chopda | Chumur | Dahanu | Dapoli | Darwaha | Daryapur | Daund | Degloor | Delhi Tanda | Deogad | Deolgaonraja | Deori | Desaiganj | Dhadgaon | Dhanora | Dharani | Dhiwadi | Dhule | Dhulia | Digras | Dindori | Edalabad | Erandul | Etapalli | Gadhchiroli | Gadhinglaj | Gaganbavada | Gangakhed | Gangapur | Gevrai | Ghatanji | Golegaon | Gondia | Gondpipri | Goregaon | Guhagar | Hadgaon | Hatkangale | Hinganghat | Hingoli | Hingua | Igatpuri | Indapur | Islampur | Jalgaon | Jalna | Jamkhed | Jamner | Jath | Jawahar | Jintdor | Junnar | Kagal | Kaij | Kalamb | Kalamnuri | Kallam | Kalmeshwar | Kalwan | Kalyan | Kamptee | Kandhar | Kankavali | Kannad | Karad | Karjat | Karmala | Katol | Kavathemankal | Kedgaon | Khadakwasala | Khamgaon | Khed | Khopoli | Khultabad | Kinwat | Kolhapur | Kopargaon | Koregaon | Kudal | Kuhi | Kurkheda | Kusumba | Lakhandur | Langa | Latur | Lonar | Lonavala | Madangad | Madha | Mahabaleshwar | Mahad | Mahagaon | Mahasala | Mahaswad | Malegaon | Malgaon | Malgund | Malkapur | Malsuras | Malwan | Mancher | Mangalwedha | Mangaon | Mangrulpur | Manjalegaon | Manmad | Maregaon | Mehda | Mekhar | Mohadi | Mohol | Mokhada | Morshi | Mouda | Mukhed | Mul | Mumbai | Murbad | Murtizapur | Murud | Nagbhir | Nagpur | Nahavara | Nanded | Nandgaon | Nandnva | Nandurbar | Narkhed | Nashik | Navapur | Ner | Newasa | Nilanga | Niphad | Omerga | Osmanabad | Pachora | Paithan | Palghar | Pali | Pandharkawada | Pandharpur | Panhala | Paranda | Parbhani | Parner | Parola | Parseoni | Partur | Patan | Pathardi | Pathari | Patoda | Pauni | Peint | Pen | Phaltan | Pimpalner | Pirangut | Poladpur | Pune | Pusad | Pusegaon | Radhanagar | Rahuri | Raigad | Rajapur | Rajgurunagar | Rajura | Ralegaon | Ramtek | Ratnagiri | Raver | Risod | Roha | Sakarwadi | Sakoli | Sakri | Salekasa | Samudrapur | Sangamner | Sanganeshwar | Sangli | Sangola | Sanguem | Saoner | Saswad | Satana | Satara | Sawantwadi | Seloo | Shahada | Shahapur | Shahuwadi | Shevgaon | Shirala | Shirol | Shirpur | Shirur | Shirwal | Sholapur | Shri Rampur | Shrigonda | Shrivardhan | Sillod | Sinderwahi | Sindhudurg | Sindkheda | Sindkhedaraja | Sinnar | Sironcha | Soyegaon | Surgena | Talasari | Talegaon S.Ji Pant | Taloda | Tasgaon | Thane | Tirora | Tiwasa | Trimbak | Tuljapur | Tumsar | Udgir | Umarkhed | Umrane | Umrer | Urlikanchan | Vaduj | Velhe | Vengurla | Vijapur | Vita | Wada | Wai | Walchandnagar | Wani | Wardha | Warlydwarud | Warora | Washim | Wathar | Yavatmal | Yawal | Yeola | Yeotmal "; s_a[22] = " Bishnupur | Chakpikarong | Chandel | Chattrik | Churachandpur | Imphal | Jiribam | Kakching | Kalapahar | Mao | Mulam | Parbung | Sadarhills | Saibom | Sempang | Senapati | Sochumer | Taloulong | Tamenglong | Thinghat | Thoubal | Ukhrul "; s_a[23] = " Amlaren | Baghmara | Cherrapunjee | Dadengiri | Garo Hills | Jaintia Hills | Jowai | Khasi Hills | Khliehriat | Mariang | Mawkyrwat | Nongpoh | Nongstoin | Resubelpara | Ri Bhoi | Shillong | Tura | Williamnagar"; s_a[24] = " Aizawl | Champhai | Demagiri | Kolasib | Lawngtlai | Lunglei | Mamit | Saiha | Serchhip"; s_a[25] = " Dimapur | Jalukie | Kiphire | Kohima | Mokokchung | Mon | Phek | Tuensang | Wokha | Zunheboto "; s_a[26] = " Anandapur | Angul | Anugul | Aska | Athgarh | Athmallik | Attabira | Bagdihi | Balangir | Balasore | Baleswar | Baliguda | Balugaon | Banaigarh | Bangiriposi | Barbil | Bargarh | Baripada | Barkot | Basta | Berhampur | Betanati | Bhadrak | Bhanjanagar | Bhawanipatna | Bhubaneswar | Birmaharajpur | Bisam Cuttack | Boriguma | Boudh | Buguda | Chandbali | Chhatrapur | Chhendipada | Cuttack | Daringbadi | Daspalla | Deodgarh | Deogarh | Dhanmandal | Dharamgarh | Dhenkanal | Digapahandi | Dunguripali | G. Udayagiri | Gajapati | Ganjam | Ghatgaon | Gudari | Gunupur | Hemgiri | Hindol | Jagatsinghapur | Jajpur | Jamankira | Jashipur | Jayapatna | Jeypur | Jharigan | Jharsuguda | Jujumura | Kalahandi | Kalimela | Kamakhyanagar | Kandhamal | Kantabhanji | Kantamal | Karanjia | Kashipur | Kendrapara | Kendujhar | Keonjhar | Khalikote | Khordha | Khurda | Komana | Koraput | Kotagarh | Kuchinda | Lahunipara | Laxmipur | M. Rampur | Malkangiri | Mathili | Mayurbhanj | Mohana | Motu | Nabarangapur | Naktideul | Nandapur | Narlaroad | Narsinghpur | Nayagarh | Nimapara | Nowparatan | Nowrangapur | Nuapada | Padampur | Paikamal | Palla Hara | Papadhandi | Parajang | Pardip | Parlakhemundi | Patnagarh | Pattamundai | Phiringia | Phulbani | Puri | Puruna Katak | R. Udayigiri | Rairakhol | Rairangpur | Rajgangpur | Rajkhariar | Rayagada | Rourkela | Sambalpur | Sohela | Sonapur | Soro | Subarnapur | Sunabeda | Sundergarh | Surada | T. Rampur | Talcher | Telkoi | Titlagarh | Tumudibandha | Udala | Umerkote "; s_a[27] = " Bahur | Karaikal | Mahe | Pondicherry | Purnankuppam | Valudavur | Villianur | Yanam "; s_a[28] = " Abohar | Ajnala | Amritsar | Balachaur | Barnala | Batala | Bathinda | Chandigarh | Dasua | Dinanagar | Faridkot | Fatehgarh Sahib | Fazilka | Ferozepur | Garhashanker | Goindwal | Gurdaspur | Guruharsahai | Hoshiarpur | Jagraon | Jalandhar | Jugial | Kapurthala | Kharar | Kotkapura | Ludhiana | Malaut | Malerkotla | Mansa | Moga | Muktasar | Nabha | Nakodar | Nangal | Nawanshahar | Nawanshahr | Pathankot | Patiala | Patti | Phagwara | Phillaur | Phulmandi | Quadian | Rajpura | Raman | Rayya | Ropar | Rupnagar | Samana | Samrala | Sangrur | Sardulgarh | Sarhind | SAS Nagar | Sultanpur Lodhi | Sunam | Tanda Urmar | Tarn Taran | Zira "; ; function print_state(state_id) { // given the id of the <select> tag as function argument, it inserts <option> tags var option_str = document.getElementById(state_id); option_str.length = 0; option_str.options[0] = new Option('Select State', ''); option_str.selectedIndex = 0; for (var i = 0; i < state_arr.length; i++) { option_str.options[option_str.length] = new Option(state_arr[i], state_arr[i]); } } function print_city(city_id, city_index) { var option_str = document.getElementById(city_id); option_str.length = 0; // Fixed by Julian Woods option_str.options[0] = new Option('Select City', ''); option_str.selectedIndex = 0; var city_arr = s_a[city_index].split("|"); for (var i = 0; i < city_arr.length; i++) { option_str.options[option_str.length] = new Option(city_arr[i], city_arr[i]); } } 我希望将所选州和城市的值传递到我的 Spring boot 应用程序中的控制器,我无法这样做,但是我创建了这个函数,它可以帮助我获取值 function getValues() { var stateValue = document.getElementById('sts').value; var cityValue = document.getElementById('state').value; alert(stateValue); alert(cityValue); } 但是我无法将其传递给我的 springboot MVC 控制器,我尝试使用 @RequestParam("stateValue") String stateValue,但它不起作用..我束手无策,请帮助我!!! @RequestParam 注释查看 name 的 <select> 属性。 第一个叫name="stt",第二个没有名字。 您需要为第二个属性指定 name,然后将其用作您的 @RequestParams <select name="stt" ... /> 应对应于 @RequestParam("stt") String state <select name="city" ... /> 应对应于 @RequestParam("city") String city (或者无论你想如何命名它们。)

回答 1 投票 0

Thymeleaf 片段内容没有取代主要内容?

我正在尝试使用 Thymeleaf 的片段。我已经创建了页眉和页脚,效果很好,但内容没有替换。 我怎么能这样做呢? 主要布局

回答 0 投票 0

如何使用 Thymeleaf 向链接添加 aria 标签以实现可访问性?

我正在努力提高使用 Thymeleaf(版本 3.0.11.RELEASE)的网页的可访问性,并希望向超链接添加 aria-label 属性。当前版本的 c...

回答 1 投票 0

由于被认为是客户端错误(例如格式错误的请求语法、无效的请求),服务器无法或不会处理请求

楼主 <div class="form-group"> <label for="landlordId">Landlord</label> <select class="form-control" id="landlordId" name="landlordId"> <option value="">- Select Landlord -</option> <option th:each="l : ${landlordsList}" th:value="${l.landlordId}" th:text="${l.name}"></option> </select> </div> 由于被认为是客户端错误的原因(例如,格式错误的请求语法、无效的请求消息帧或欺骗性的请求路由),服务器无法或不会处理请求。 当我使用这个我的后端是 Spring MVC 时出现此错误 我Cheak了与实体类匹配的所有属性,我无法得到任何改变 将“名称”更改为随机名称,并在控制器上使用@RequestParam(“名称”) <select class="form-control" id="landlordId" name="abcd"> <option value="">- Select Landlord -</option> <option th:each="l :${landlordsList}" th:text="${l.name}" th:value="${l.landlordId}"></option> </select> @PostMapping("/saveLease") public String saveLease(Lease lease, @RequestParam("abcd") int abcd) { Landlords landlords = landlordsService.FindById(abcd); lease.setLandlordId(landlords); leaseService.Save(lease); return "redirect:/leaseList"; }

回答 0 投票 0

如何在Thymeleaf中使用“map.get(key)” - Broadleaf Ecom

我有一个哈希图(字符串,列表),传递到 Thymeleaf 页面。我在页面上找到了这张地图,并且可以访问它。 如何使用 Thymeleaf 执行 map.get(key) ?我只需要获取

回答 8 投票 0

Thymeleaf 中的希伯来语文本显示不正确

我有一个 Spring MVC 应用程序,使用 Thymeleaf 作为视图技术。我在 HTML 中显示希伯来语文本时遇到困难。我有一个简单的 HTML 文件,其中包含一些希伯来语文本: 我有一个 Spring MVC 应用程序,使用 Thymeleaf 作为视图技术。我在 HTML 中显示希伯来语文本时遇到困难。我有一个简单的 HTML 文件,其中包含一些希伯来语文本: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <link rel="stylesheet" href="css/style.css"> <title>Document</title> </head> <body> <h1>שלום</h1> </body> </html> 当使用 JSP(使用 Spring MVC)提供此页面时,它看起来很好。当切换到 Thymeleaf 时,会出现问题。我尝试在 Thymeleaf 视图解析器上设置字符编码: @Bean public ThymeleafViewResolver viewResolver(){ ThymeleafViewResolver viewResolver = new ThymeleafViewResolver(); viewResolver.setTemplateEngine(templateEngine()); viewResolver.setCharacterEncoding("UTF-8"); return viewResolver; } 但这并没有帮助。 您可以尝试将 setForceTemplateMode 设置为 true吗? @Bean public ThymeleafViewResolver viewResolver(){ ThymeleafViewResolver viewResolver = new ThymeleafViewResolver(); viewResolver.setTemplateEngine(templateEngine()); viewResolver.setCharacterEncoding("UTF-8"); viewResolver.setForceTemplateMode(true); // <- changed here! return viewResolver; }

回答 1 投票 0

使用 thymsleaf 删除会话

我创建了一个CommonServiceImpl,它负责删除Spring Boot项目中的会话。但是我通过 getAoccur 得到了潜在的空指针访问错误,请帮助我消除这个错误...

回答 1 投票 0

Spring Boot 应用程序在每个请求时都会重定向到 /login

我正在开发一个用于管理医疗设备和公司的 Spring Boot 应用程序。我已经使用处理搜索请求的 SearchController 建立了一个基本结构。然而,每当我尝试

回答 1 投票 0

不支持“POST”方法 - Spring

我正在尝试向 Spring 发送 post 请求,但总是收到此错误:不支持方法“POST” 尝试发布数据时我也收到此错误 我正在使用 eclipse 和 spring boot,我的项目...

回答 1 投票 0

隐藏字段值空白Thymeleaf

我有一个 thymeleaf 表单,其中有 2 个隐藏字段。我使用 th:value 指定隐藏字段的值,并将这些字段绑定到一个对象。 我有一个 thymeleaf 表单,其中有 2 个隐藏字段。我使用 th:value 指定隐藏字段的值,并将这些字段绑定到一个对象。 <div class="w-row"> <div class="w-col w-col-6"> <div class="question_text_sc"> <p th:text="${questionVO.questionText}" /> <p th:text="${questionVO.questionStem}" /> <p th:text="${sequenceNo}" /> <p th:text="${quizID}" /> </div> </div> <div class="question_stem_sc"></div> <div class="w-col w-col-6"> <div> <div class="w-form"> <form class="w-clearfix" id="email-form" name="email-form" data-name="Email Form" action="#" th:action="@{/quiz/question}" th:object="${userResponseVO}" method="post"> <div th:each="option: ${questionVO.answerOptions}" class="w-radio radio_select" th:id="${'radio_1'}"> <input class="w-radio-input" id="radio" type="radio" name="answer_sc" th:field="*{answerID}" th:value="${option}"/> <label class="w-form-label" id="answer_1" for="radio"><p th:text="${option}" /></label> </div> <input type="hidden" name="sequenceNo" th:field="*{sequenceNo}" th:value="${sequenceNo}" ></input> <input type="hidden" name="quizID" th:field="*{quizID}" th:value="${quizID}"></input> <button class="button submit_answr" type="submit">Next Question</button> </form> 我想将 quizID 和equenceNo 字段与对象中的相应字段绑定。第 6 行和第 7 行正确解析了序列号/测验 id 的值并显示它。但是,表单内的 th:value 标记中未解析相同的值。该值为空,并且没有任何内容绑定到对象字段。 在此请求您的帮助。 编辑: 当我从隐藏元素中删除 th:field 属性时,代码有效。但我想将它绑定到一个对象变量,以便服务器可以处理它。 ` 我们可以通过两种方式解决您的情况 第一种方法: <input type="hidden" th:value="${question.id}" th:attr="name='quizID'" /> 第二种方式: <input type="hidden" th:value="${question.id}" name="quizID" /> 如果您使用 thymeleaf th:field="*{sequenceNo}",thymeleaf 的内部代码的工作方式如下, 它将检查特定元素是否有任何 name 属性(如果可用)th:字段值覆盖名称属性。 名称=“序列号” 它将检查特定元素是否有任何 id 属性,如果它不可用 th:field value 添加的新属性,即)id。 id=“序列号” 对我来说帮助设置th:field(或者实际上是name)使用th:attr th:value="${question.id}" th:attr="name='questionIds[' + ${iter.index} + ']'" 在我的示例中,我想从 ${question} 获取值,但输入中的目标是 questionIDs[i] 在像你这样的简单问题中 name=answerId 应该足够了。 Thymeleaf 似乎无法识别 hidden 字段。要修复它,请尝试以下操作: 将输入定义为文本(而不是隐藏)。 定义类似 "display:none" 的样式标签,以便在屏幕上隐藏元素。 结果应该是这样的: <input type="text" th:field="*{parameters[${stat.index}].field}" style="display:none;"> 希望有帮助。 假设您要收集对某个页面的评论。然后,除了注释之外,您还必须向控制器传输页面名称。当然,用户不必重新输入该页面的名称。该信息必须传递给控制器,但 th:field 仅映射用户输入的值,而不映射默认生成的值。 但您可以将此页面的名称作为 URL 中的参数传递给控制器。 在 html 中,你有类似的东西: <form th:action="@{/saveComment(lastPage=${lastPage})}" th:object="${comments}" method="post" enctype="multipart/form-data"> <div class="row"> ................................................................................. <h2>Enter your comment</h2> <textarea th:field="${comments.comment}" rows="10" cols="100" name="comment" id="comment"></textarea> <label for="comment">Your comment here</label><br /> <input type="submit" name ="submit" value="Submit" /> </div> </form> In controller, you put stuff like this: @PostMapping("/saveComment") public String saveComment(Comments comments, String lastPage) { comments.setPage_commented(lastPage); commentsRepository.save(comments); return "redirect:/"; } 我遇到过这样的情况 <input type="hidden" th:field="*{releaseArtifactDtos[__${itemStat.index}__].fileName}" th:value="${releaseArtifactDto.fileName}" /> 但这并没有 <input type="hidden" th:field="*{releaseArtifactDtos[__${itemStat.index}__].versionName}" th:value="${versionProperty.version.versionName}" 输入值将仅显示为“值”,而不进行赋值。 我可以通过在此之后立即转储该值来证明该值的存在。 <span th:text="${versionProperty.version.versionName}" /> 隐藏输入类型中字段和值的组合似乎有点错误。 最终对我有用的是 <input type="hidden" th:attr="name='releaseArtifactDtos[' + ${itemStat.index} + '].versionName'" th:value="${versionProperty.version.versionName}"

回答 5 投票 0

文件上传到 ClassPathResource - IOException

我想将管理员添加的图像(添加类别)上传到项目目录中的文件夹中,但我尝试在控制器的帮助下执行此操作,但它会抛出未处理的异常类型 IOException @PostMapping...

回答 1 投票 0

使用类路径资源的 IO 异常

我想将管理员添加的图像(添加类别)上传到项目目录中的文件夹中,但我尝试在控制器的帮助下执行此操作,但它会抛出未处理的异常类型 IOException @PostMapping...

回答 1 投票 0

如何在 Thymeleaf 中执行 if-else 操作?

在 Thymeleaf 中执行简单的 if-else 的最佳方法是什么? 我想在 Thymeleaf 中实现相同的效果 在 Thymeleaf 中执行简单的 if-else 的最佳方法是什么? 我想在 Thymeleaf 中实现与相同的效果 <c:choose> <c:when test="${potentially_complex_expression}"> <h2>Hello!</h2> </c:when> <c:otherwise> <span class="xxx">Something else</span> </c:otherwise> </c:choose> 在 JSTL。 到目前为止我所想到的: <div th:with="condition=${potentially_complex_expression}" th:remove="tag"> <h2 th:if="${condition}">Hello!</h2> <span th:unless="${condition}" class="xxx">Something else</span> </div> 我不想评估potentially_complex_expression两次。这就是为什么我引入局部变量condition。但我还是不喜欢同时使用 th:if="${condition} 和 th:unless="${condition}"。 重要的是我使用了两个不同的 HTML 标签:比如说 h2 和 span。 你能建议一个更好的方法来实现它吗? Thymeleaf 具有相当于 <c:choose> 和 <c:when> 的功能:Thymeleaf 2.0 中引入了 th:switch 和 th:case 属性。 它们按照您的预期工作,使用 * 作为默认情况: <div th:switch="${user.role}"> <p th:case="'admin'">User is an administrator</p> <p th:case="#{roles.manager}">User is a manager</p> <p th:case="*">User is some other thing</p> </div> 请参阅 this 以获取语法的快速说明(或 Thymeleaf 教程)。 免责声明:根据 StackOverflow 规则的要求,我是 Thymeleaf 的作者。 我尝试使用此代码来查明客户是否已登录或匿名。我确实使用了 th:if 和 th:unless 条件表达式。非常简单的方法来做到这一点。 <!-- IF CUSTOMER IS ANONYMOUS --> <div th:if="${customer.anonymous}"> <div>Welcome, Guest</div> </div> <!-- ELSE --> <div th:unless="${customer.anonymous}"> <div th:text=" 'Hi,' + ${customer.name}">Hi, User</div> </div> 除了 Daniel Fernández 之外,我还想分享我与安全相关的示例。 <div th:switch="${#authentication}? ${#authorization.expression('isAuthenticated()')} : ${false}"> <span th:case="${false}">User is not logged in</span> <span th:case="${true}">Logged in user</span> <span th:case="*">Should never happen, but who knows...</span> </div> 这里是混合了“身份验证”和“授权”实用程序对象的复杂表达式,它为 thymeleaf 模板代码生成“真/假”结果。 “身份验证”和“授权”实用程序对象来自 thymeleaf extras springsecurity3 库。 当 'authentication' 对象不可用或授权.expression('isAuthenticated()') 计算结果为 'false' 时,表达式返回 ${false},否则返回 ${true}。 你可以使用 If-then-else: (if) ? (then) : (else) 示例: 'User is of type ' + (${user.isAdmin()} ? 'Administrator' : (${user.type} ?: 'Unknown')) 对于提出同样问题的新人来说可能很有用。 另一种解决方案 - 您可以使用局部变量: <div th:with="expr_result = ${potentially_complex_expression}"> <div th:if="${expr_result}"> <h2>Hello!</h2> </div> <div th:unless="${expr_result}"> <span class="xxx">Something else</span> </div> </div> 有关局部变量的更多信息: http://www.thymeleaf.org/doc/tutorials/2.1/usingthymeleaf.html#local-variables 在更简单的情况下(当html标签相同时): <h2 th:text="${potentially_complex_expression} ? 'Hello' : 'Something else'">/h2> 使用 th:switch 作为 if-else <span th:switch="${isThisTrue}"> <i th:case="true" class="fas fa-check green-text"></i> <i th:case="false" class="fas fa-times red-text"></i> </span> 使用 th:switch 作为 switch <span th:switch="${fruit}"> <i th:case="Apple" class="fas fa-check red-text"></i> <i th:case="Orange" class="fas fa-times orange-text"></i> <i th:case="*" class="fas fa-times yellow-text"></i> </span> 另一种解决方案是使用 not 得到相反的否定: <h2 th:if="${potentially_complex_expression}">Hello!</h2> <span class="xxx" th:if="${not potentially_complex_expression}">Something else</span> 正如文档中所解释的,这与使用th:unless是一样的。正如其他答案所解释的: 此外,th:if有一个逆属性,th:unless,我们可以有 在前面的示例中使用 而不是使用不在 OGNL 内部 表情 使用 not 也可以,但恕我直言,使用 th:unless 比用 not 否定条件更具可读性。 <div th:switch="true"> <div th:case="${condition}=='1'">answer1...</div> <div th:case="${condition}=='2'">answer2...</div> <div th:case="*">answer3...</div> </div> <div th:switch="${user.role}"> <p th:case="'admin'">User is an administrator</p> <p th:case="#{roles.manager}">User is a manager</p> <p th:case="*">User is some other thing</p> </div> <div th:with="condition=${potentially_complex_expression}" th:remove="tag"> <h2 th:if="${condition}">Hello!</h2> <span th:unless="${condition}" class="xxx">Something else</span> </div> <div style="width:100%"> <span th:each="i : ${#numbers.sequence(1, 3)}"> <span th:if="${i == curpage}"> <a href="/listEmployee/${i}" class="btn btn-success custom-width" th:text="${i}"></a </span> <span th:unless="${i == curpage}"> <a href="/listEmployee/${i}" class="btn btn-danger custom-width" th:text="${i}"></a> </span> </span> </div> 在此输入图片描述 If-then-else 有 2 种变体。 第一: <form method="get" th:action="@{/{id}(id=${user.isAdmin()}?'admin':'user')}"> <input type="submit" value="to Main"/> </form> 第二: <th:block th:if!="${branchMessages.isEmpty()}"> ... </th:block> <th:block th:unless="${branchMessages.isEmpty()}"> ... </th:block> 当我想根据用户的性别显示照片时,这对我有用: <img th:src="${generou}=='Femenino' ? @{/images/user_mujer.jpg}: @{/images/user.jpg}" alt="AdminLTE Logo" class="brand-image img-circle elevation-3"> 当使用 2 个独立的块时,If 和 except 有时无法提供预期结果。 If 和 else 也可以通过在第一个块中使用 if 语句来实现条件 1 (TRUE),第二个 if 语句是第一个条件失败时的第二个块中的替代选择 (FALSE)。 希望这会有所帮助。 <div th:with="condition=${potentially_complex_expression}" th:remove="tag"> //True <h2 th:if="${if_condition}">Hello!</h2> //False <h2 th:if="${alternative_for_false}">Something else</h2> </div> 如何在 Thymeleaf 中执行 if-else 操作? 上面的问题可以通过使用 th:if 和 th:unless 条件概念来解决。 有时,您需要模板的片段仅在满足特定条件时才出现在结果中。 例如,您希望在导航面板上根据登录用户角色显示菜单选项。 例如,管理员用户将有不同的菜单选项,简单用户将有不同的菜单选项。 其语法如下。 <div th:if="${condition}"> <p>True condition related code.</p> </div> <div th:unless="${condition}"> <p>False condition related code</p> </div> 您可以从此资源探索更多内容。 如果喜欢请订阅频道。

回答 15 投票 0

Thymeleaf 每个循环都带有复选框标签,不检查值

我在互联网上找不到解决方案,所以也许更多的眼睛可以提供帮助。 我有慈善捐款表格。它使用 thymeleaf 模板引擎。 我使用模式将所需的对象传递给视图...

回答 1 投票 0

发生意外错误(类型=内部服务器错误,状态=500)。模板解析时发生错误

所以我基本上是使用 spring boot、thymleaf、html、css 制作一个电子商务项目。我在解析 thymeleaf 模板时遇到服务器错误,这是出现意外错误...

回答 1 投票 0

© www.soinside.com 2019 - 2024. All rights reserved.